INF: Index Tuning Wizard Best Practices

Article translations Article translations
Article ID: 311826 - View products that this article applies to.
This article was previously published under Q311826
Expand all | Collapse all

On This Page

SUMMARY

The Index Tuning Wizard (ITW) is a great resource for tuning a large number of queries with minimum effort.

The ITW will make some recommendations but will not necessarily recommend all indexes that might potentially be useful. ITW makes more and better recommendations on a database that is not tuned than on one that is well-tuned but has a couple of troublesome queries.

MORE INFORMATION

Best Practices

  • Make sure that the wizard has a good, representative workload to work with. Depending on your business needs, your sample may have to include all queries against a particular database, or perhaps only those generated by a certain program, server, or batch job. You may have to sample throughout the day or only for a specific period.

  • You can generate the workload by using SQL Profiler to trace to a file. Filter out information that you do not plan to tune, such as calls to SQLAgent or to non-relevant application databases on the server.

  • The ITW can affect performance, so you need to run it on a test system or during off-peak hours. Avoid the use of the ITW on a production system during business hours.

  • Before you run the ITW, update the statistics on your database. The more accurate the statistics are, the better the recommendations will be.

  • If you run the ITW on a test system, make sure the tables, constraints, indexes, data selectivity, and number of rows are the same as those on your production system. This consistency increases the accuracy of the recommendations.

  • Remove all index hints from the queries in the sample.

  • By default, the disk on which the database resides limits the size and number of the indexes recommended. To change the settings that control the size and number of indexes, use the Advanced Options tab.

  • To capture all events and data columns you need for a trace use the "SQLProfilerTSQL_Replay" template that is provided with SQL Server 2000. Refer to the Replaying Traces topic in SQL Server Books Online for more details.

Considerations

  • The maximum number of queries that will be tuned from a single workload is 32,767. However, the default number of queries is much lower and you have to increase the maximum number of queries to tune when you start the Index Tuning Wizard.

  • For the ITW to recommend indexes, there must be a significant amount of data in the tables being tuned.

  • It is best if only one user tries to tune a database at a time.

  • If a potential index only provides a small benefit over an existing index, the potential index is not included in the recommendations.

  • Queries with optimizer hints are not tuned. However, any indexes specified in a hint are listed among the recommended indexes, even though other indexes on that table are not considered. Therefore, it is best to remove index hints before tuning queries.
  • Refer to the Index Tuning Wizard topic in SQL Server Books Online for a list of items that can keep the ITW from recommending indexes. Some examples of what the ITW will not tune are:

    • Primary key constraints and unique indexes.
    • Cross-database queries.
    • Queries with temporary tables or system tables.
    • Tables with less than 10 pages allocated.

Common Issues with the Index Tuning Wizard

For additional information about the common issues you may experience with the Index Tuning Wizard, click the article numbers below to view the articles in the Microsoft Knowledge Base:
293177 BUG: Hypothetical Clustered Index From Index Tuning Wizard May Cause Recompile Loop
290414 FIX: Index Tuning Wizard Fails to Remove Hypothetical Clustered Indexes
278274 PRB: Index Tuning Wizard Does Not Suggest Proper Index When There Is Not Enough Space
299914 FIX: Executing MAX or MIN Aggregate Functions on Column with Hypothetical Clustered Index May Result in CPU SPIN
270600 PRB: Index Tuning Wizard May Not Recommend Indexes for SQL Statements in Triggers
298828 FIX: Query Analyzer Stops Responding and Cannot be Started Until Visual Studio Analyzer is Stopped

Additional Information

  • If you close the ITW abnormally, you may have stranded hypothetical indexes that you have to manually remove. Use this code to find all hypothetical indexes left behind in a database:
    SELECT object_name(id), name AS Hypothetical FROM sysindexes
    WHERE indexproperty(id, name, 'IsHypothetical') = 1
    						
    For an example of how to drop these hypothetical indexes, see the sample code in the following Microsoft Knowledge Base article:
    293177 BUG: Hypothetical Clustered Index From Index Tuning Wizard
  • If you have to schedule the ITW to run after hours, use the ITWiz utility that is documented in SQL Server Books Online.

  • The ITW generates reports after it completes. Review those reports for details on what indexes the ITW considered and what indexes the ITW recommends.

REFERENCES

For additional information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
298475 HOW TO: Troubleshoot Application Performance Issues
243589 INF: Troubleshooting Slow-Running Queries on SQL Server 7.0 or Later
SQL Server Books Online; topics: "Index Tuning Wizard"; "Troubleshooting the Index Tuning Wizard"; "Viewing and Analyzing Traces"; "Saving Traces and Templates"

Index Tuning Wizard for Microsoft SQL Server 7.0

Index Tuning Wizard for Microsoft SQL Server 2000

Troubleshooting the Index Tuning Wizard

Designing an Index

Delaney, Kalen. Inside Microsoft SQL Server 2000. Microsoft Press, 2000. ISBN 0-7356-0998-5.

Soukup, Ron. Inside Microsoft SQL Server 7.0. Microsoft Press, 1999. ISBN 0-7356-0517-3.

Properties

Article ID: 311826 - Last Review: September 15, 2003 - Revision: 3.4
APPLIES TO
  • Microsoft SQL Server 2000 Standard Edition
  • Microsoft SQL Server 7.0 Standard Edition
Keywords: 
kbinfo KB311826

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com