SQL Tuning Advisor provides many suggested indexes that share many the same columns.. should I add all of them?

StackOverflow https://stackoverflow.com/questions/23091242

Question

When using SQL Tuning Advisor to analyze a SQL Profiler file it recommends 5 or more non-clustered indexes on a couple tables I selected that are joined often.

These indexes share many of the same columns. For example, if the table has columns A, B, C, D and E the indexes might be

1  A B E
2  A B C D
3  B D E

and so forth

Is it common practice to add all of these suggestions or should I try to determine which suggestion will include all of the join-able columns?

Was it helpful?

Solution

You are entering a very complex area of DBA work. When do I have to many indexes? and when can I use more coverng indexes?

If the table is written to a lot, you need to ensure that you do not have many indexes as this will degrade the insert/update/delete performance.

Also, you do not want over lapping indexes, as this will waste storage space.

What you do need to note though is that the order and columns selected for the index does matter.

I always use a telephone dictionary as an example.

If your index in the back was by firstname, lastname , a serch for surname = Smith would result in an entire index scan, if not a table scan.

So choosing your indexes is very important.

And also remember the use of included columns, this would greatly improve query performance where you find key lookups in the execution plans, but the trade off is that you use additional storage space.

Using an index advisor is great if you are starting to learn about query optimization, but I would recomend rather understanding the execution plans, and also narrowing down which type of queries you need the most for certain tables.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top