Sybase Technical Library - Product Manuals Home
[Search Forms] [Previous Section with Hits] [Next Section with Hits] [Clear Search] Expand Search

Chapter 20 Advanced Optimizing Tools [Table of Contents] Chapter 22 Access Methods and Query Costing
for Single Tables

Performance and Tuning Guide Volumes 1 - 3 (Online Only)

[-] Chapter 21 Query Tuning Tools

Chapter 21

Query Tuning Tools

This chapter provides a guide to the tools that can help you tune your queries.

The tools mentioned in this chapter are described in more detail in the chapters that follow.

Overview

Adaptive Server provides the following diagnostic and informational tools to help you understand query optimization and improve the performance of your queries:

How tools may interact

showplan, statistics io, and other commands produce their output while stored procedures are being run. The system procedures that you might use for checking table structure or indexes as you test optimization strategies can produce voluminous output when diagnostic information is being printed. You may want to have hard copies of your table schemas and index information, or you can use separate windows for running system procedures such as sp_helpindex.

For lengthy queries and batches, you may want the save showplan and statistics io output in files. You can do so by using "echo input" flag to isql. The syntax is:

isql -P password -e -i input_file -o outputfile

Using showplan and noexec together

showplan is often used in conjunction with set noexec on, which prevents SQL statements from being executed. Issue showplan, or any other set commands, before you issue the noexec command. Once you issue set noexec on, the only command that Adaptive Server executes is set noexec off. This example shows the correct order:

set showplan on
set noexec on
go
select au_lname, au_fname
    from   authors
    where  au_id = "A137406537"
go

noexec and statistics io

While showplan and noexec make useful companions, noexec stops all the output of statistics io. The statistics io command reports actual disk I/O; while noexec is in effect, no I/O takes place, so the reports are not printed.

How tools relate to query processing

Many of the tools, for example, the set commands, affect the decisions made by the optimizer. showplan and dbcc traceon(302, 310) show you optimizer decision-making. dbcc traceon(302,310) shows intermediate information as analysis is performed, with dbcc traceon(310) printing the final plan statistics. showplan shows the final decision on access methods and join order.

statistics io and statistics time provide information about how the query was executed: statistics time measures time from the parse step until the query completes. statistics io prints actual I/O performed during query execution.

noexec allows you to obtain information such as showplan or dbcc traceon(302,310) output without actually executing the query.


Chapter 20 Advanced Optimizing Tools [Table of Contents] Chapter 22 Access Methods and Query Costing
for Single Tables