What Is SQLTXPLAIN and Its Use Cases
What Is SQLTXPLAIN and Its Use Cases
SQLT Overview
SQLTXPLAIN, also known as SQLT, is a tool provided by Oracle Server Technologies Center of
Expertise - ST CoE. SQLT main methods input one SQL statement and output a set of diagnostics
files. These files are commonly used to diagnose SQL statements performing poorly or those which
generate wrong results.
Once installed, you can use SQLT to analyze a SQL statement by passing its text within a
script (including bind variables), or by providing its SQL_ID.
SQLT main methods connect to the database and collect execution plans, Cost-based Optimizer
CBO statistics, schema objects metadata, performance statistics, configuration parameters, and
other elements that influence the performance of the one SQL being analyzed.
SQLT may use the Oracle Diagnostic and/or the Oracle Tuning Packs if your site has a
license for them. These two provide enhanced functionality to the SQLT tool. During SQLT
installation you can specify if one of these two packages is licensed by your site. If none, SQLT
still provides some basic information that can be used for initial SQL diagnostics.
Free add-on tool that helps to diagnose SQL statements performing poorly
Inputs one SQL statement and outputs a set of diagnostics reports and files including a
Test Case.
Frequently used by Support and Development
Newest SQLT code available for 10.2 and 11g
Older versions for 8i, 9i and 10.1 are available
Same SQLT code for UNIX, Linux and Windows
Self-contained in its own schema: SQLTXPLAIN
Un-wrapped readable PL/SQL
Comprehensive content
Select “Summary” option to check available plans information also its show which is best plan and
worst plan.
We need to have a set of SQLT files (sqlt_sNNNNN_method.zip) from two executions of the SQLT tool.
They can be from any method (XTRACT, XECUTE or XPLAIN) and they can be from the same or different
systems. They do not have to be from same release or platform. For example, a SQLT from 10g on
Linux and a SQLT from 11g on Unix can be compared.
To use the COMPARE method you need 3 systems: SOURCE1, SOURCE2 and COMPARE. The 3 could all be
different, or all the same. For example, SOURCE1 could be PROD, SOURCE2 DEV and COMPARE DEV. In
other words, you could do the COMPARE in one of the sources. Or the COMPARE could be done on a 3rd
and remote system.
Basically you need to restore the SQLT repository from both SOURCES into the COMPARE system. In
most cases it means "restoring" the SQLT repository from at least one SOURCE into the COMPARE.
Once you have both SQLT repositories into the COMPARE system, then you can execute this method.
Steps:
Perform the equivalent steps for the 2nd SOURCE if needed. You may want to follow its readme file.
Execute the COMPARE method connecting into SQL*Plus as SYS. You will be asked to enter which 2
statements you want to compare.
START sqlt/run/sqltcompare.sql
# cd sqlt
# sqlplus sqltxplain
SQL> START [path]sqltcompare.sql [STATEMENT_ID 1] [STATEMENT_ID 2]
SQL> START run/sqltcompare.sql 36748 88079
SQL> START run/sqltcompare.sql
Sample output:
When we need to create outlines in source system to apply on target system, SQLT is the one
of the easiest method to do this.
Generate SQT output and find the best plan is source system and create custom profile like below.
Provide input with the sql_id and hash value from source system to generate custom profile and run
in source system.
@/export/home/oracle/sqlt/utl/coe_xfr_sql_profile.sql <SQLID> <HASVALUE>
And it produces the sql file like “coe_xfr_sql_profile_<sql_id>_<plan hash value>.sql”
Copy this sql file and run in target system.
Note: A SQL Profile contains additional statistics of this SQL statement for the query optimizer
to generate a better execution plan. An outline contains hints for this SQL statement for the
query optimizer to generate a better execution plan.
$SQL>@sqlhc.sql T <SQL_ID>