sqlt xplore: the sqlt xplain hidden child

38
SQLT XPLORE The SQLT XPLAIN Hidden Child Carlos Sierra

Upload: carlos-sierra

Post on 26-May-2015

5.107 views

Category:

Software


3 download

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

Page 1: SQLT XPLORE: The SQLT XPLAIN hidden child

SQLT XPLOREThe SQLT XPLAIN Hidden Child

Carlos Sierra

Page 2: SQLT XPLORE: The SQLT XPLAIN hidden child

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

Page 3: SQLT XPLORE: The SQLT XPLAIN hidden child

Enkitec (c) 2014 3

SQLT XPLORE• Introduction• Input and Output• Screen Shots• Demo

Page 4: SQLT XPLORE: The SQLT XPLAIN hidden child

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

Page 5: SQLT XPLORE: The SQLT XPLAIN hidden child

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

Page 6: SQLT XPLORE: The SQLT XPLAIN hidden child

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

Page 7: SQLT XPLORE: The SQLT XPLAIN hidden child

Enkitec (c) 2014 7

XPLORE Mechanics• Iterates over – CBO Parameters and Fix Control

• For each iteration– Executes input SQL– Captures Plan

• Reports Summary

Page 8: SQLT XPLORE: The SQLT XPLAIN hidden child

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

Page 9: SQLT XPLORE: The SQLT XPLAIN hidden child

Enkitec (c) 2014 9

XPLORE HTML Report• Plans Summary• Discovered Plans• Baseline• Completed Tests for each Plan• Execution Plans

Page 10: SQLT XPLORE: The SQLT XPLAIN hidden child

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

Page 11: SQLT XPLORE: The SQLT XPLAIN hidden child

Enkitec (c) 2014 11

Page 12: SQLT XPLORE: The SQLT XPLAIN hidden child

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

Page 13: SQLT XPLORE: The SQLT XPLAIN hidden child

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

Page 14: SQLT XPLORE: The SQLT XPLAIN hidden child

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

Page 15: SQLT XPLORE: The SQLT XPLAIN hidden child

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

Page 16: SQLT XPLORE: The SQLT XPLAIN hidden child

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

Page 17: SQLT XPLORE: The SQLT XPLAIN hidden child

Enkitec (c) 2014 17

Uninstalling XPLORE• Execute sqlt/utl/xplore/uninstall.sql as SYS• Provide test case user when asked

Page 18: SQLT XPLORE: The SQLT XPLAIN hidden child

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

Page 19: SQLT XPLORE: The SQLT XPLAIN hidden child

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 ]

Page 20: SQLT XPLORE: The SQLT XPLAIN hidden child

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)

Page 21: SQLT XPLORE: The SQLT XPLAIN hidden child

Enkitec (c) 2014 21

Input tc.sql Sample

Page 22: SQLT XPLORE: The SQLT XPLAIN hidden child

Enkitec (c) 2014 22

Page 23: SQLT XPLORE: The SQLT XPLAIN hidden child

Enkitec (c) 2014 23

Page 24: SQLT XPLORE: The SQLT XPLAIN hidden child

Enkitec (c) 2014 24

Input q1.sql Sample

Page 25: SQLT XPLORE: The SQLT XPLAIN hidden child

Enkitec (c) 2014 25

Page 26: SQLT XPLORE: The SQLT XPLAIN hidden child

Enkitec (c) 2014 26

Page 27: SQLT XPLORE: The SQLT XPLAIN hidden child

Enkitec (c) 2014 27

Input q2.sql Sample

Page 28: SQLT XPLORE: The SQLT XPLAIN hidden child

Enkitec (c) 2014 28

Page 29: SQLT XPLORE: The SQLT XPLAIN hidden child

Enkitec (c) 2014 29

Page 30: SQLT XPLORE: The SQLT XPLAIN hidden child

Enkitec (c) 2014 30

Page 31: SQLT XPLORE: The SQLT XPLAIN hidden child

Enkitec (c) 2014 31

Input q3.sql Sample

Page 32: SQLT XPLORE: The SQLT XPLAIN hidden child

Enkitec (c) 2014 32

Page 33: SQLT XPLORE: The SQLT XPLAIN hidden child

Enkitec (c) 2014 33

Page 34: SQLT XPLORE: The SQLT XPLAIN hidden child

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

Page 35: SQLT XPLORE: The SQLT XPLAIN hidden child

Enkitec (c) 2014 35

Page 36: SQLT XPLORE: The SQLT XPLAIN hidden child

Enkitec (c) 2014 36

Demo Time

Page 37: SQLT XPLORE: The SQLT XPLAIN hidden child

Enkitec (c) 2014 37

References• SQLTXPLAIN (SQLT)– MOS 215187.1

Page 38: SQLT XPLORE: The SQLT XPLAIN hidden child

Enkitec (c) 2014 38

Contact Information• [email protected]• carlos-sierra.net• @csierra_usa