Understanding the Information You Have Gathered

You have taken a number of steps to get information about your optimizer problem. Here is an explanation of each of these steps:


select @@version

select @@version displays the version of Adaptive Server you are running, including the SWR level and platform.


sp_help

sp_help provides more accurate information about a table than the script you used to create the table and its indexes. In the event that indexes have been added or changed or that columns have been added via alter table, sp_help will show the present state of the table(s).


set showplan on

The set showplan on command shows which query plan the optimizer has chosen for your query. Use set showplan on before running any query or procedure you will be analyzing.

In some cases you may need to issue the set noexec on command to save time when you are running a very long query. The order of these commands is important:

set showplan on
set noexec on
go
<query text...>
go

There are several important items of information to look for when reading showplan output:

Refer to “Using set showplan” in the Performance and Tuning Guide for more information on interpreting showplan results.


set statistics io on

Since any analysis of a performance problem will require knowledge of the number and types of I/Os performed for the query, the set statistics io on command is critical.

NoteIf your query is taking very long to complete, using statistics io and statistics time may not be feasible. If you analyze your long-running query using set noexec on, you cannot obtain I/O information since noexec on stops all the output of statistics io.

The set statistics io on command provides you with the following information:


set statistics time on

set statistics time on provides the following information:

The output of set statistics time on may be useful, but it is not usually a significant factor in most optimizer analyses.


dbcc traceon (3604)

This trace flag sends the output of dbcc traceon (302) and dbcc traceon (310) to the screen.


dbcc traceon (302)

This trace flag returns the optimizer's cost estimates for each SARG and join clause in the query. Trace flag 302 is documented in greater detail in “Tuning with dbcc traceon” in the Performance and Tuning Guide.

Here is the information to watch for in dbcc traceon (302) output:


dbcc traceon (310)

dbcc traceon (310) gives the optimizer cost estimates for permutations of a join or joins. Examine the dbcc traceon (310) output to determine whether the query is “connected.” If so, it indicates that the join will not result in a cartesian product. The statement “query is connected” will appear after the optimizer has performed cost estimates on all possible indexes, as indicated in the output of dbcc traceon (302) .