SQL Server Performance

Indexed View Vs. Table

Discussion in 'General DBA Questions' started by alimmia, Apr 20, 2006.

  1. alimmia New Member

    Would anyone tell me what is the advantages choosing indexed views over tables? As far as the spacing is concern, both the indexed view and the table take space. Then, why shouldn't I create a table with the sub-set of data instead of indexed view? Is the indexed view is fasted then the table with the same amount of data? Why should be faster?<br /><br />Thanks[<img src='/community/emoticons/emotion-1.gif' alt=':)' />].<br />Alim<br /><br />Alim Mia
  2. mmarovic Active Member

    I would not create indexed view with subset of data from the single table. However if I need performance improvement over the join of two or more tables and composite index on columns from more the one table joined I would use indexed view. That way I don't have to write the code for synchronizing base table changes with "permanent derived table". In case of indexed view sql server will do it automagicaly for me.
  3. alimmia New Member

    Thanks for the comments. If I use "SELECT INTO" statement to create the new table which will always bring the latest table structure, then why I need to create indexed views. I can also create a new table with the result set of all the joins. So, Why do I need the Indexed View. I do not understand the purpose of the indexed view since the view also take space!<br /><br />Thanks[<img src='/community/emoticons/emotion-1.gif' alt=':)' />],<br />Alim<br /><br />Alim Mia
  4. KarenWallace New Member

    An indexed view is self-updating, immediately reflecting changes to the underlying tables. If you don't need that real-time updating -- and it sounds like you don't -- then it's probably best to avoid the overhead required for the database to monitor the underlying tables in order to keep the indexes of the view up to date.
  5. Adriaan New Member

    An indexed view serves a different purpose than a table. Also - if there is no table, then there can be no view.

    A table is for storing actual data.

    A view can be used for presenting data from tables in a user-friendly manner, for instance by replacing foreign key values that are substitute keys, with the natural key or a full name from the lookup table, or by adding user-friendly aliases for column names.

    A view can be used to hide sensitive or irrelevant information for specific users. You can grant users permissions on the view, and not on the table, so the hidden information is truly inaccessible to them.

    A view can be used to 'pre-process' joins, making life easier when you create queries - you don't have to set up the joins between the underlying tables again and again.

    A view is the only object in SQL Server where you can create a single index that covers columns from more than one table. This is useful for queries where you have criteria spread over multiple tables.

    I don't think there is much point in adding an index on a view if it covers a (set of) column(s) from only a single underlying table: such an index should already be defined on the table.
  6. alimmia New Member

    Thanks Guys for all the valuable comments [<img src='/community/emoticons/emotion-1.gif' alt=':)' />]!<br /><br />Alim Mia
  7. joeyjacoby New Member

    Why should be faster? Alim - do people actually understand you or do you just ramble sentences together using broken english?
  8. satya Moderator

    Please adhere to forum policies and do not comment on others replies here.
    I see that Original Poster is happy with the reply and should have any more questions will come back here.
    If you have any additional comments (technical to subject) to add to above replies then please do so.
    Hope this helps.

Share This Page