Indexed View Vs. Table

Last post 08-27-2008 5:33 AM by satya. 7 replies.
Page 1 of 1 (8 items)
Active Topics My Discussions Unanswered Sort Posts: Previous Next
  • 04-20-2006 11:03 AM

    Indexed View Vs. Table

    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?

    Thanks[:)].
    Alim

    Alim Mia
  • 04-20-2006 11:28 AM In reply to

    Re: Indexed View Vs. Table

    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.
  • 04-20-2006 12:13 PM In reply to

    Re: Indexed View Vs. Table

    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!

    Thanks[:)],
    Alim

    Alim Mia
  • 04-21-2006 4:45 PM In reply to

    Re: Indexed View Vs. Table

    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.
  • 04-22-2006 2:36 AM In reply to

    Re: Indexed View Vs. Table

    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.
  • 04-24-2006 8:53 AM In reply to

    Re: Indexed View Vs. Table

    Thanks Guys for all the valuable comments [:)]!

    Alim Mia
  • 08-26-2008 1:45 PM In reply to

    Re: Indexed View Vs. Table

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

  • 08-27-2008 5:33 AM In reply to

    • satya
    • Top 10 Contributor
    • Joined on 11-05-2002
    • United Kingdom
    • Posts 23,751
    • Microsoft MVP
      Moderator

    Re: Indexed View Vs. Table

    Joey

    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.

    -Satya S K J

    SQL Server MVP



    Knowledge is Power, you will gain by sharing it. SSQA.net - Invisible contributions to the users & visible success in SQL Community.
Page 1 of 1 (8 items)
Active Topics   My Discussions    Unanswered Posts


© 2010 Jude O'Kelly All Rights Reserved.