|
The Index Tuning Wizard analyzes a trace file and inspects the SQL statements we previously recorded.
The wizard will be able to decide when an index should or should not be created. If the wizard determines
an index should be created, the details are handled automatically. (This tutorial will not discuss what
index type to use in a custom situation.)

Fig. 7 – Index Tuning Wizard – Select Database. On this screen, ensure the proper database is selected.
I often uncheck the Keep all existing indexes option. This is because the wizard may determine certain
indexes should be dropped if they are not being used.
Also, when the Tuning mode is set to “Thorough,” the analysis takes longer. If you are dealing with a very
large trace file on a real system, it’s a good idea to run this process and analysis after-hours.

Fig. 8 – Index Tuning Wizard – Specify Workload. A workload file is the trace file containing all
the recorded SQL Statements and details. For the purposes of this tutorial, we’ll ignore the settings
in the Advanced Options screen.

Fig. 9 – Index Tuning Wizard – Select Tables. Select the tables you want to tune. In most cases,
use the Select All Tables button to get index recommendations on all the tables in the system.

Fig. 10 – Index Tuning Wizard - Processing. A series of messages will pop up and notify you of processing
progress. On a small trace file, the processing should be quick. However, if you are working with real trace file
with many entries, processing can take hours. It might overtax the system resources if performed on a
production server during business hours. Because of this, we recommend you run the Index Tuning Wizard after-hours
when only you are on the system.
In our example, the load file is so small that it processes in about 7 seconds.

Fig. 11 – Index Tuning Wizard – Index Recommendations. Here are the recommendations. Based on our
application usage, the wizard recommends we create four or more new indexes (indicated by the icons with
the yellow star). If we allow the wizard to create these indexes for us, we should realize a 67% performance
improvement! These are estimates, but tend to be pretty accurate.

Fig. 12 – Index Tuning Wizard – Apply or Schedule. It is now time to actually create the indexes.
We are working on a development database with no other users at the moment, so we will simply select
“Apply changes” and “Execute recommendations now.” This creates the indexes for us.
Creating indexes can take a while depending on how many rows are in each table. More important,
creating indexes applies locks on the database. This can cause problems with other users attempting
to use the system.
Production database note: We recommend you always backup your database before applying any changes
to it. Also, to avoid production conflict, process and create indexes only after-hours. However,
you can create a trace file in Profiler during production hours in order to get an accurate record of
real-users' activity on the system.
|