Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

Query Performance Using Indexed View Expand / Collapse
Posted Thursday, March 27, 2014 12:41 AM


Group: General Forum Members
Last Login: Sunday, November 2, 2014 9:45 PM
Points: 12, Visits: 53
Hello SQL Experts,

Have one table at warehousing side which contains 100 millions of rows. Actually I succeeded to reduce performance(by adding missing indexes) with great extent in case when worst criteria is used but still it is not at acceptable level.

There can be 25 fields used as criteria to query on this table. Some other tables are also using in join but cost of joining those table is low.

Then I come across Indexed view where it is possible to store aggregate result before hand and I can query to this indexed view with NOEXPAND option but designing index view is critical task for me.

1. Do I have to add all fields/columns into view definition which can be part of criteria?? and grouping all those columns to store aggregate results??

2. Also I have to create unique clustered index on this view. which fields I have to to consider part of it?

3.Other non clustered index I do add as required but will this hamper lot of maintenance cost?

If you already have designed indexed views please do provide your views for the same.

hope so I have explained problem here very well.

Many thanks in advance.
Post #1555282
Posted Thursday, March 27, 2014 2:37 AM

Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 8:45 AM
Points: 3,997, Visits: 4,713

1. You don't have to add all fields/columns, unless you must to. Indexed view is very close to table. It's biggest utility comes when the goal is to optimize aggregate operations.
2. Follow the same rules for designing indexes as for tables (e.g.
3. Consider that indexes updates are affecting views same as tables. However, nonclustered indexes are useful, but try to cover as much as possible with min number of indexes.

Consider the table size, which in your case is pretty big.


Igor Micev,
SQL Server developer at Seavus
Post #1555309
Posted Thursday, March 27, 2014 4:33 AM



Group: General Forum Members
Last Login: Today @ 10:23 AM
Points: 17,173, Visits: 32,135
I think Igor largely nails it. I'd concentrate the aggregations into the view. That's the stuff that is going to be the most costly in your queries, so doing that work ahead of time is best. As for the rest, it's hard to offer advice without seeing the code and the structures. Read my books? Not great help, but that's about all I can add here.

"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of:
SQL Server Query Performance Tuning
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1555346
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse