Quo Vadis SQLTXPLAIN
Who we are Experts At Your Service > Over 50 specialists in IT infrastructure > Certified, experienced, passionate Based In Switzerland > 100% self-financed Swiss company > Over CHF8 mio. Turnover Leading In Infrastructure Services > More than 150 customers in CH, D & F > Over 50 SLAs dbi FlexService contracted Quo Vadis SQLTXPLAIN 22.11.2017 Page 2
About me Clemens Bleile Senior Consultant +41 78 677 51 09 clemens.bleile[at]dbi-services.com Quo Vadis SQLTXPLAIN 22.11.2017 Page 3
SQLTXPLAIN The motivation for the presentation > 12.1.12.1 October 20, 2015 > 12.1.14 December 6, 2015 > 12.1.160429 April 29,2016 > August 2017: 10.2, 11.1, 11.2 and 12.1 download > 12.2.170914 September 14,2017 Hurricane Irma > 12.2.171004 October 4th, 2017 > October 2017: 10.2, 11.1, 11.2, 12.1 and 12.2 download Page 4
Agenda 1.SQL Tuning (according documentation) 2.SQLTXPLAIN 3.SQLd360 4.SQL Tuning 2017 5.Summary Quo vadis? Is a Latin phrase meaning Where are you going? Source: Wikipedia Quo Vadis SQLTXPLAIN 22.11.2017 Page 5
SQL Tuning > According the Oracle Documentation > Manual Tuning Tools 2 4 1 3 5 Quo Vadis SQLTXPLAIN 22.11.2017 Page 6
SQL Tuning According the Oracle Documentation Page 7
SQL Tuning According the Oracle Documentation Page 8
SQL Tuning According the Oracle Documentation Page 9
SQL Tuning According the Oracle Documentation Page 10
SQL Tuning According the Oracle Documentation Automated Tuning Tools > ADDM > SQL Tuning Advisor > SQL Access Advisor > SQL Plan Management > SQL Performance Analyzer Page 11
SQL Tuning According the Oracle Documentation Manual Tuning Tools > Execution Plans > Explain Plan > AUTOTRACE > V$SQL_PLAN > DBMS_XPLAN-Package to view EXPLAIN PLAN, V$SQL_PLAN > Real-Time SQL Monitoring and Real-Time Database Operations > V$SQL_MONITOR > V$SQL_PLAN_MONITOR > Use with other V$-Views like V$ACTIVE_SESSION_HISTORY, V$SESSION > Application Tracing > tkprof, trcsess > Optimizer Hints Page 12
SQL Tuning Manual Tuning Tools > Why is it slow? > To know why something is slow lots of data may need to be reviewed: > Statistics > Table, Index, Partition, Column > History of statistics > Metadata > History of the SQL (good and bad plans) > Bind variables peeked and captured > Optimizer parameters used > Difference between calculated and real cardinality in the plan > Etc. > There is not a single tool within the standard Oracle release to get that ALL Page 13
SQLTXPLAIN > What is SQLTXPLAIN and why using it? > Methods > Main Report > SQLTXPLAIN issues 2 4 1 3 5 Quo Vadis SQLTXPLAIN 22.11.2017 Page 14
SQLTXPLAIN What is SQLTXPLAIN? SQLT (SQLTXPLAIN) is a tool that inputs one SQL statement and outputs a set of comprehensive diagnostic files for SQL performance analysis and tuning. Page 15
SQLTXPLAIN Why SQLTXPLAIN? > First version developed 1999 by Oracle employee Carlos Sierra in the Center of Expertise (CoE) > The tool was used in different environments (e.g. Peoplesoft, Siebel, Ebusiness Suite) to tune SQL > Objective was to get all required data around a SQL-statement (to be able to tune it) > Became THE standard tool to analyze SQL in Oracle Support > SQL tuning issue could be analyzed offline > Time to fix a SQL-tuning-problem was reduced significantly Page 16
SQLTXPLAIN SQLTXPLAIN characteristics > Free download (with MOS access) and use > 9i, 10g, 11g and 12c databases > Unix, Linux and Windows platforms > Unwrapped source (SQL and PL/SQL) > Installs under its own schemas (self-contained) > Small footprint (space and CPU) > Not intrusive (does not expose application data) > Recognizes RAC environments > Helps to expedite a SQL performance analysis and tuning Page 17
SQLTXPLAIN Why SQLTXPLAIN MOS Search: SQLTXPLAIN Page 18
SQLTXPLAIN SQLTXPLAIN main methods > XPLAIN > Stand-alone SQL placed in a flat text file > XTRACT > Memory or AWR resident SQL, identified by its hash_value or sql_id > XECUTE > Stand-alone script that contains one SQL, together with the declaration and values of its bind variables > XTRXEC > XTRACT and XECUTE combined Page 19
SQLTXPLAIN SQLTXPLAIN Output Reports > Main html report > CBO trace 10053 and SQL trace 10046 > Readme text file > TKPROF > Log files Scripts > Metadata > Set CBO Environment > TC SQL > TC Script > TC Builder Page 20
SQLTXPLAIN Main Report See example Main Report Page 21
SQLTXPLAIN SQLTXPLAIN Issues > Data not presented graphically > Heavy HTML-report > Requires installation (2 schemas) > XTRACT (usually used) does not include execution details (computed versus real cardinality) > Requires MOS access to download it Page 22
SQLTXPLAIN SQLTXPLAIN Issues https://carlos-sierra.net/2012/04/03/what-is-sqltxplain/ Page 23
SQLd360 > Why SQLd360 > How to use it? > Main Report 2 4 1 3 5 Quo Vadis SQLTXPLAIN 22.11.2017 Page 24
SQLd360 What is SQLd360 SQLd360 is a free tool that provides a 360-degree overview around a SQL statement. The output is a single zip file that allows offline analysis, trend analysis and detailed root-cause investigations. The content of the zip is a set of small reports, each specific to an area of interest, easy to navigate through an index file. https://mauro-pagano.com/2015/02/16/sqld360-sql-diagnostics-collection-made-faster/ Page 25
SQLd360 Why SQLd360 In comparison to SQLT it provides: > Data graphically > Light HTML-report > Requires no installation > Requires no MOS access Page 26
SQLd360 How to use it? > Download > https://github.com/mauropagano/sqld360/archive/master.zip > Unzip > Run $ unzip sqld360-master.zip $ cd sqld360-master $ sqlplus / as sysdba SQL> @sqld360.sql 0vy6pt4krb3gm T > Check html $ unzip sqld360_233927_7ws837zynp1zv.zip $ firefox 00001_sqld360_233927_7ws837zynp1zv_index.html Page 27
SQLd360 Main Report See an example Main Report Page 28
SQL Tuning 2017 > Some thoughts > Pro s and Con s of the tools > My subjective opinion 2 4 1 3 5 Quo Vadis SQLTXPLAIN 22.11.2017 Page 29
SQL Tuning 2017 Some thoughts Do normal DBAs need all the info provided in SQLT? > SQLTXPLAIN was mainly written for Oracle Support > Do we (DBAs, Developers) need to understand what the optimizer is doing in detail? > If there is a misbehaviour, shouldn t Oracle Support comment on that? How predictive is an execution plan with all adaptive features today? > Especially plans with adaptive statistics are difficult to comprehend Page 30
SQL Tuning 2017 Some thoughts Do normal DBAs need all the info provided in SQLT? > Yes, I think so. Being familiar with SQLT (or SQLd360) allows to fix a SQL-performance issue faster. > We may not fully understand what s going on, but we should be able to fix an issue without Oracle Support. How predictive is an execution plan with all adaptive features today? > In 12.2. the adaptive statistics are switched off by default. > Tools like SQLT or SQLd360 are becoming more important again Adaptive Query Optimization ADAPTIVE PLANS Join Methods Parallel Distribution ADAPTIVE STATISTICS Dynamic Statistics Automatic Reoptimization SQL Plan Directives Page 31
SQL Tuning 2017 Some thoughts SQL Tuning approaches > Tuning by design (Developer): Know the SQL and the data. Provide appropriate access structures and statistics to get the expected plan. Considers data changes (growth, data skew). > Troubleshooting (DBA): Find out where the calculated plan is wrong (difference between computed and real cardinality) and fix the issue. > Mix of above approaches. Things may have to be improved iteratively. Page 32
SQL Tuning 2017 Some thoughts SQL Tuning approaches > To be able to tune a SQL we need to > know all the metadata around a SQL SQLT, SQLd360 > measure runtime statistics SQLTXECUTE, GATHER_PLAN_STATISTICS, 10046-trace, SQL Monitor > know the DB features Concepts, Education, Experience Page 33
SQLTXPLAIN Pro s and Con s ALL Information around a SQLstatement provided Requires 2 schemas in the database. Easy navigation in HTML (Go to top, Drill down, Appropriate topic in context) Useful utilities to fix a plan quickly. Data not presented graphically. Heavy HTML-report. Automatic execution of SQL through XTRXEC possible to get computed versus actual cardinality Page 34
SQLd360 Pro s and Con s Non-intrusive No context sensitive links to related information. Some statistics presented graphically You have to know where to start. Most impacting plan step highlighted graphically No method to see computed versus actual cardinality. Page 35
My subjective opinion SQL Tuning 2017 My subjective opinion: > To tune a SQL quickly a tool like SQLTXPLAIN and/or SQLd360 is still very helpful > Due to my personal experience with the tool and its navigation possibilities in the main report, SQLTXPLAIN is still what I m using today (if possible) > SQLd360 is a possible alternative for SQLTXPLAIN for many DBAs (who e.g. cannot accept SQLTXPLAIN s restrictions) > The utilities provided by SQLTXPLAIN (e.g. coe_xfr_sql_profile.sql) could be very handy in stressful tuning situations Page 36
Summary 1 > SQL Tuning 2017 2 3 4 5 Quo Vadis SQLTXPLAIN 22.11.2017 Page 37
Summary SQL Tuning 2017 > Get all metadata around a SQL using a tool like SQLT or SQLd360 > Measure what happens when running the SQL: > SQLTXECUTE > GATHER_PLAN_STATISTICS with DBMS_XPLAN.DISPLAY_CURSOR(format=> ALLSTATS LAST ) > 10046 trace with a format utility like tkprof > SQL Monitor > SQL_PLAN_LINE_ID in ASH > focus is on > where most time is spent > where we do have a misestimate between calculated and real cardinality > Based on above data make an analysis and fix the issue locally > Verify result Page 38
Summary AI and autonomous DBs? > What about Artificial Intelligence and autonomous DBs? > In my opinion there will always be cases which need manual tuning. > I.e. a tool like SQLTXPLAIN or SQLd360 will have its value also in the future. > SQL Tuning as a service? Page 39
Basel Delémont Zürich Nyon Any questions? Please do ask! We would love to boost your IT-Infrastructure How about you? Quo Vadis SQLTXPLAIN 22.11.2017 Page 40
Let s meet at booth 242