sqlt xplore: the sqlt xplain hidden child
DESCRIPTION
Have you ever been in a situation where after a database upgrade one or two SQL statements start performing poorly? If you have then maybe you have tested the performance of these queries by setting your Optimizer to the pre-upgrade release, and discovered the performance was restored. What do you do next? SQLT XPLORE (the hidden child of SQLTXPLAIN) can give you some answers to this problem. SQLT XPLORE uses brute force analysis to explore some aspects of a SQL statement. The typical case is this: A SQL statement has a performance regression after a database software upgrade. Setting Optimizer Features to the pre-upgrade release causes the performance of the SQL to be restored, so there is a high level of confidence the root cause of the regression was a change to the Optimizer. Since setting the Optimizer to a pre-upgrade release is not a solution but a workaround, the problem becomes "How to find which particular change on the CBO is causing the regression of this particular SQL?". SQLT XPLORE was designed and built to help answer this difficult question. This session covers SQLT XPLORE under the hood, and all the benefits an expert DBA can obtain of its use. Keep in mind that SQLT XPLORE, which is packaged within SQLT, is a free multi-use tool!TRANSCRIPT
SQLT XPLOREThe SQLT XPLAIN Hidden Child
Carlos Sierra
Enkitec (c) 2014 2
Carlos Sierra• SQLTXPLAIN + SQL Health-Check SQLHC +• Consultant/Developer/DBA/Design/+• Oracle Performance + SQL Tuning• Oracle Database Health-Check• Tools + Scripts• Speaker Question
Everything
Enkitec (c) 2014 3
SQLT XPLORE• Introduction• Input and Output• Screen Shots• Demo
Enkitec (c) 2014 4
SQLTXPLAIN (SQLT)• Free SQL Tuning Tool• Oracle 10g to 12c• Linux/UNIX/Windows• Available @ MOS 215187.1• Includes SQLT Test Case (TC) and XPLORE
Enkitec (c) 2014 5
SQLT Test Case (TC)• Metadata to create a SQL Tuning test case– SQL Text with bind variables and their values– Schema Objects creation script– CBO Statistics– Schema Objects mapping
Enkitec (c) 2014 6
What is SQLT XPLORE?• Brute Force stand-alone module • Under sqlt/utl/xplore out of sqlt.zip• Acts on top of a SQLT TC – Or any SQL on a Test System
• Discovers several Execution Plans
Enkitec (c) 2014 7
XPLORE Mechanics• Iterates over – CBO Parameters and Fix Control
• For each iteration– Executes input SQL– Captures Plan
• Reports Summary
Enkitec (c) 2014 8
XPLORE Input and Output• Inputs one script with one SQL• Outputs a zip with– HTML Report– SQL Monitor zip– Staging SQL Script– Execution Log
Enkitec (c) 2014 9
XPLORE HTML Report• Plans Summary• Discovered Plans• Baseline• Completed Tests for each Plan• Execution Plans
Enkitec (c) 2014 10
SQL Monitor ZIP• Only on 11g• Requires Oracle Tuning Pack– Controlled by XPLORE execution parameter
• You may need to embed /*+ MONITOR */ hint• One SQL Monitor Report for each iteration
Enkitec (c) 2014 11
Enkitec (c) 2014 12
When to use XPLORE?• SQL performance analysis – After a database software upgrade
• Bad Plan is reproducible on Test System• Good Plan can be obtained using Optimizer
Features Enabled (OFE) set to prior release• You want to narrow reason of regression
Enkitec (c) 2014 13
Multiple Uses• SQL Performance Regression after Upgrade• Long Parse Time Analysis• Wrong Results Analysis– Diagnostic of Query Transformations Errors
• Discover effect of “disabled” fixes• Find a better performing Plan
Enkitec (c) 2014 14
When NOT to use XPLORE?• When your SQL to be analyzed may corrupt or
update data• When using XPLORE with data and each
iteration takes more than a few seconds
Enkitec (c) 2014 15
XPLORE Prerequisites• Create a SQL Script with one SQL– Binds are allowed
• SQL on script must include /* ^^unique_id */• Script must be capable to execute stand alone• SQL may or may not return rows – XPLORE works with and without data
Enkitec (c) 2014 16
XPLORE Installation• Place your input SQL Script into sqlt/utl/xplore• Execute sqlt/utl/xplore/install.sql as SYS• Input test case user and its password– XPLORE will be executed as test case user
Enkitec (c) 2014 17
Uninstalling XPLORE• Execute sqlt/utl/xplore/uninstall.sql as SYS• Provide test case user when asked
Enkitec (c) 2014 18
XPLORE use• Navigate to sqlt/utl/xplore/• Connect as the test case user• Set the CBO environment (optional)• Execute create_xplore_script.sql• Execute dynamically generated xplore_script
Enkitec (c) 2014 19
Create XPLORE Script Parameters• XPLORE Method: [ XECUTE | XPLAIN ]• Include CBO Parameters: [ Y | N ]• Include Exadata Parameters: [ Y | N ]• Include Fix Control: [ Y | N ]• Generate SQL Monitor Reports: [ N | Y ]
Enkitec (c) 2014 20
XPLORE Script Parameters• Script to be executed on each iteration– Script must reside on sqlt/utl/xplore– Must contain /* ^^unique_id */– Must be capable of stand-alone error-free exec
• Password for test case user– Each iteration re-connects and sets CBO env (opt)
Enkitec (c) 2014 21
Input tc.sql Sample
Enkitec (c) 2014 22
Enkitec (c) 2014 23
Enkitec (c) 2014 24
Input q1.sql Sample
Enkitec (c) 2014 25
Enkitec (c) 2014 26
Enkitec (c) 2014 27
Input q2.sql Sample
Enkitec (c) 2014 28
Enkitec (c) 2014 29
Enkitec (c) 2014 30
Enkitec (c) 2014 31
Input q3.sql Sample
Enkitec (c) 2014 32
Enkitec (c) 2014 33
Enkitec (c) 2014 34
Input q4.sql• Complex SQL• Good performance on 9i• Poor performance on 11.2.0.4• 9 Tables and close to 100 Indexes• Histograms• Over 90 bind variables
Enkitec (c) 2014 35
Enkitec (c) 2014 36
Demo Time
Enkitec (c) 2014 37
References• SQLTXPLAIN (SQLT)– MOS 215187.1
Enkitec (c) 2014 38
Contact Information• [email protected]• carlos-sierra.net• @csierra_usa