• SQLRNNR (1/7/2013)


    dwilliscp (1/7/2013)


    SQLRNNR (1/7/2013)


    dwilliscp (1/7/2013)


    GSquared (1/7/2013)


    "When to index" isn't a question of the query. Not really. It's a question of what you're trying to do.

    There's no way to tell, from what you wrote, wether you should index something or not.

    Start out with a book on performance tuning. Read online articles on it, too, but pick out a good book as a first step.

    My readings are:

    A Guide for the Accidental DBA, Mastering Server Profiler, Performance Tuning DMV, SQL Server Tacklebox.

    Any suggestions?

    I'd start with these

    A Guide for the Accidental DBA

    Performance Tuning DMV

    Those are the books that I have already read, in the past year. They are helpful, but do not cover the details of when to create an index. (I believe the index script came out of the accidental DBA book.)

    Besides the link that Gail just provided, you can use that script as a starting point. But do not rely solely on the output of that script. For scripts similar to that, I don't even start to look at the proposed index unless I know it is related to a poorly performing piece of the application. Or, I will loosely regard the results starting at an impact level of 1000 or greater.

    You should be careful with the column order in the provided script as well. Investigate the Execution Plan that is associated to the missing index and ensure the column order is correct.

    Thanks for the help you and Gail provided. I was trying to find a better approach than what I am currently doing... that is starting with the query, pulling the top 10 and looking at what tables they are using (to see if there are any indexes on them, and if they are similuar). Then I look at the execution and see if they are spending a lot of time doing table scans (well it is a percent, but you get the idea). I guess the one change is to work my way down to do all those with 1000 ranking or higher.