Implementing indexed views on a SQL Server
0
Q:
Implementing indexed views on a SQL Server
How can I implement indexed views on our SQL Server? Is there an example that shows how they would improve query performance?
ASKED: Oct 8 2008  3:35 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
46795 pts.
0
A:
 RATE THIS ANSWER
+1
Click to Vote:
  •   1
  •  0
  • AddThis Social Bookmark Button
Indexed views are typically only truly useful on the largest of systems. They are useful when you have a common query against two or more tables where you need a single index against both tables to improve the performance of the query.

In my 10 years of being a DBA I've needed them maybe twice.

To create an indexes view, setup your tables that you wish to create the view on. They should have primary keys defined, as well as indexes created on the columns which will be used for the JOIN syntax.

Setup your view, and be sure to use the SCHEMABINDING clause when creating the view.

You can now create a clustered index, and non-clustered indexes on the view.

Do keep in mind that all inserts, updates and deletes to any of the underlying tables will now take longer than they did before as these additional indexes will need to be updated. If you remove a large amount of data from any of these tables (such as a data purge) the increased amount of time to be used will be very noticeable.
Last Answered: Oct 9 2008  5:59 AM GMT by Mrdenny   46795 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Mrdenny   46795 pts.  |   Oct 9 2008  5:59AM GMT

Check out my SQL Server blog “SQL Server with Mr Denny” for more SQL Server information.

 
0