SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Query Performance Using Indexed View


Query Performance Using Indexed View

Author
Message
mote.ajit2
mote.ajit2
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
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.
Igor Micev
Igor Micev
SSCertifiable
SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)

Group: General Forum Members
Points: 5944 Visits: 5084
Hi,

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. http://www.sqlservercentral.com/articles/Indexing/68563/).
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.

Regards,
Igor

Igor Micev,
SQL Server developer at Seavus
My blog: www.igormicev.com
Grant Fritchey
Grant Fritchey
SSC-Forever
SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)

Group: General Forum Members
Points: 40925 Visits: 32666
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 and SQL Server Execution Plans
Product Evangelist for Red Gate Software
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search