SlideShare a Scribd company logo
(Obscure) Tools of the Trade   for Tuning Oracle SQLs   [email_address] Tony Jambu Melbourne, Australia
Agenda Tuning Methodology Generating Explain Plan & Tracing TRCSESS DBMS_XPLAN SQL*Plus and Autotrace TRCANLZR - Trace Analyzer SQLT - SQLTXPLAIN  Oracle Active Report Other Tools
Tuning Methodology Where do you start? In development or production? Do you have the volume of data? Proactive or Reactive ? Explain Plans only or database tracing? Explain Plan: Quick but is ‘best guess’ Need to validate changes
Tuning Methodology Tracing: Numerous methods to trace Produces raw data from the execution Not practical for some very large data warehouse SQLs How At own session , other sessions or database level? Numerous ways of turning tracing on
Tracing Various methods Init.ora parameters alter session set event….. eg 10046, 10053, alter [session|system] set sql_trace=true; dbms_session.set_sql_trace(true), dbms_system.set_bool_param_in_session(...), dbms_system.set_sql_trace_in_session(...), dbms_support.start_trace, dbms_support.start_trace_in_session(...), dbms_system.set_ev(…), ***dbms_monitor.* - Oracle 10g and up. Replaces DBMS_SUPPORT oradebug session_event …
Tracing Add name identifier to trace file alter session set  tracefile_identifier ='MyTrc_'; Session Information are useful for end-to-end tracing and can be set with Machine : The name of your machine Module : The application module name Action : What you are doing eg ‘Before Transforming data’  or ‘Aggregating base data’ Service : The service name Client ID : Either logon id or set with  dbms_session.set_identifier(‘A Name’) – Case sensitive
Tracing Trace Enabling New : DBMS_MONITOR.CLIENT_ID_ TRACE _ENABLE('account_update') Means, auto enable tracing for all sessions with the identifier ‘account_update’ To disable: DBMS_MONITOR.CLIENT_ID_ TRACE _DISABLE('account_update');
Tracing Statistics Enabling New : DBMS_MONITOR.CLIENT_ID_ STAT _ENABLE('account_update') Enable stats gathering for Client_ID =  ‘account_update’ To disable: DBMS_MONITOR.CLIENT_ID_ STAT _DISABLE('account_update'); Also possible for Service, Module & Action DBMS_MONITOR.SERV_MOD_ACT_STAT_DISABLE( service_name => 'ACCTG',  module_name => 'GLEDGER',  action_name => 'INSERT ITEM'); *** 10g
TRCSESS Tkprof Only works with one file at a time How to handle multiple files like PX files? trcsess Oracle utility that  aggregates/consolidates  and format numerous  trace files into  a single file Trcsess output= output_file_name ] [session= session_id ] [clientid= client_id ] [service= service_name ] [action= action_name ] [module= module_name ] [ trace_files ]
SQL&Plus and AUTOTRACE An SQL*Plus command Usage: set autot[race]  {off | on | trace[only]}  [exp[lain]]  [stat[istics]] ON – returns results Traceonly – Do not return results Exp – Shows execution plan Stat – Gathers execution stats
SQL&Plus and AUTOTRACE set autotrace  on : Shows the  execution plan  as well as  statistics  of the statement.  set autotrace on explain: Displays the  execution plan  only.  set autotrace  on statistics : Displays the  statistics  only.  set autotrace  traceonly : Displays the  execution plan  and the  statistics  (as set autotrace on does), but doesn't print a query's result.  set autotrace  off : Disables all autotrace
SQL&Plus and AUTOTRACE Pre-requisite: PLAN_TABLE.  Be careful that you have your own copy of the plan_table and is the latest version in $ORACLE_HOME/rdbms/admin/utlxplan.sql  In 11g, no need as there is a public Synonym to  SYS.PLAN_TABLE$ . Pre-requisite: PLUSTRACE Role Users will require the  PLUSTRACE role  ($ORACLE_HOME/sqlplus/admin/plustrce.sql)
SQL&Plus and AUTOTRACE DEMO_1   (not for dba) cd Trace Analyzer sqlplus tjambu/tjambu set autotrace trace exp @TJ_Test1a.sql set autotrace trace exp STAT @TJ_Test1a.sql -See diff between ON and STATS
DBMS_XPLAN DBMS_XPLAN is an explain plan formatter Has 4 Procedures DISPLAY –  Displays the explain plan from the Plan Table DISPLAY_CURSOR –  Displays the Execution plan of a SQL in the cursor cache DISPLAY_AWR –  Displays the Execution plan for a SQL_ID in the AWR DISPLAY_SQLSET –  Displays the Execution plan for statement in a SQL tuning set
DBMS_XPLAN dbms_xplan.display (Explain Plan) Usage: SELECT * FROM table(DBMS_XPLAN.DISPLAY); Usage  Accepts 3 parameters Table_Name -  Name of plan table, default value 'PLAN_TABLE'. Statement_ID  - Statement id of the plan to be displayed, default value NULL. Format  - Level of detail displayed, default value 'TYPICAL'. Also 'BASIC', 'ALL', 'SERIAL‘.
DBMS_XPLAN DBMS_XPLAN.DISPLAY  – Examples select * from table(dbms_xplan.display ('PLAN_TABLE', 'TJ2' ,  'BASIC ')); select * from table(dbms_xplan.display ('PLAN_TABLE', 'TJ2' ,  'SERIAL ')); select * from table(dbms_xplan.display ('PLAN_TABLE', 'TJ2' ,  'TYPICAL ')); select * from table(dbms_xplan.display ('PLAN_TABLE', 'TJ2' ,  'ALL ')); SELECT tf.* FROM  DBA_HIST_SQLTEXT  ht, table (DBMS_XPLAN. DISPLAY_AWR (ht.sql_id,null, null,  'ALL' )) tf  WHERE ht.sql_text like ‘% EV_INTERMEDIATE %’;
DBMS_XPLAN DBMS_XPLAN.DISPLAY_CURSOR    ( Execution  Plan)  -  DEMO 2   Run with and without GATHER_PLAN_STATS hint SELECT *   FROM TABLE (   DBMS_XPLAN.display_cursor (NULL,    NULL,    'ALLSTATS LAST +peeked_binds')   ); cd DBMS_XPLAN sqlplus sh/sh @demo_dbms_xplan1.sql @demo_dbms_xplan2.sql
TRCA -  TRACE ANALYZER Tool from Oracle Support Center of Expertise Available from Metalink – Doc ID: 224270.1 Input : One or more trace file from 10046 Output : Diagnostics report in HTML and Text format.  Excellent for tuning SQLS Contains information about all objects accesses and their statistics NOTE :  Developers now have access to trace files on server!
TRCA -  TRACE ANALYZER Usage Only need one file ( trcanlzr.sql)  to run from client 4 ways Analyzing  one  trace on the same system where it was generated. sqlplus user/passwd @trcanlzr  file.trc  Analyzing  a set  of related traces (PX) on the same system where they were generated.  sqlplus user/passwd @trcanlzr  TraceFiles.lis Analyzing  one  trace on a  different  system (target) to the one where it was generated (source). Analyzing  a set  of related traces (PX) on a  different  system (target) to where they were generated (source)
TRCA -  TRACE ANALYZER DEMO 3 Only need one SQL file to run from client cd trca/run sqlplus sh/sh @trcanlzr.sql TraceFiles.lis
SQLT-  SQLTXPLAIN Tool from Oracle Support Center of Expertise Available from Metalink – Doc ID: 215187.1  Input : Single SQL statement, SQL_ID or  HASH_VALUE Output : Diagnostics report in HTML and Text format reporting on execution plans, CBO statistics, schema objects metadata, performance statistics, configuration parameters, and similar elements Can utilise Oracle Diagnostic and the Oracle Tuning Packs Understands database links
SQLT-  SQLTXPLAIN Execution – 3 Methods XPLAIN  Method  - smaller output, does not understand bind variables XTRACT  Method  -  for when the SQL still resides in memory or in the Automatic Workload Repository AWR.  Need SQL_ID or HASH_VALUE. XECUTE  Method - provides the maximum level of detail. Executes the SQL being analyzed, then it produces a set of diagnostics files. Its major drawback is that if the SQL being analyzed takes long to execute, this method will take longer.  For statements < 1hr
SQLT-  SQLTXPLAIN DEMO 4 - XPLAIN Input: Single SQL # cd sqlt # sqlplus sh/sh SQL> @run/sqltxplain.sql ../TJ_Test1.sql
SQLT-  SQLTXPLAIN DEMO 5 - XTRACT Input: SQL_ID or HASH_VALUE -- Check TOAD for SQL_ID or HASH_VALUE or  -- Check trace file    cd sqlt sqlplus sh/sh SQL> @run/sqltxtract.sql 2751883218   hv =2751883218 ad='92da13d4'  sqlid ='5y7bskyk0ctyk‘ @run/sqltxtract.sql 2751883218 Or @run/sqltxtract.sql 5y7bskyk0ctyk
SQLT-  SQLTXPLAIN DEMO 6 - XECUTE Input: Single SQL statement cd sqlt sqlplus sh/sh SQL> @run/ sqltxecute.sql  ../TJ_Test1.sql
Oracle Active Report- Real-Time SQL Monitoring New in 11gR2 EM function via DBMS_SQLTUNE Extract session/SQL information and presents infomation in GUI/Adobe Flash Needs internet connection Good for database support.  Able to capture and encapsulate all the information in one HTML report. dbms_sqltune. report_sql_detail dbms_sqltune. report_sql_monitor .
Oracle Active Report- Real-Time SQL Monitoring DEMO 7 cd  “Active Report” sqlplus tjambu/tjambu SQL> @ report_sql_monitor.sql SQL> @ report_sql_detail.sql
Other Tools - TOAD TOAD functionalities Explain Plan customisation Explain Plan comparison Trace file browser Tkprof utility
Summary  There are different approaches to SQL tuning We covered some less known tools Which to choose depends on your particular situation Do try out some of the newer tools For feedback & discussion:  [email_address]
xxxxxxx XXX Xxx XXX XXX
Texas Memory Systems ,  http://www.superssd.com/whitepapers.htm http://www.texmemsys.com/files/whitepaper_opera.pdf Anand Tech, http://anandtech.com/storage/showdoc.aspx?i=3631   http://www.anandtech.com/storage/showdoc.aspx?i=3531&p=1   StorageSearch.com/SolidData,  http://www.storagesearch.com/soliddata-art2-comparisons.pdf   References & Acknowledgement
Session:  715  Title: Understanding Solid State Drives (SSD)  Technology for Databases, Presenter: Tony Jambu For feedback & discussion:  [email_address] Please fill in the evaluation form. What did we do to reduce the End of Fin year processing from 2days to 4 hours? ANSWER Select Star Mailing list http://groups.yahoo.com/group/Select_Star/   or email  [email_address]
 

More Related Content

PPT
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
PPTX
Oracle Database 12c - Data Redaction
PPTX
Oracle Data Redaction
PPTX
DBA Commands and Concepts That Every Developer Should Know
PPTX
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
PPTX
Oracle Data Redaction
PPTX
Dan Hotka's Top 10 Oracle 12c New Features
PPTX
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
Oracle Database 12c - Data Redaction
Oracle Data Redaction
DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
Oracle Data Redaction
Dan Hotka's Top 10 Oracle 12c New Features
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know

What's hot (20)

PPTX
Oracle Data Redaction - UKOUG - TECH14
PPTX
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
PPTX
Oracle Database 12.1.0.2 New Features
PPTX
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
PPTX
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expre...
PPTX
Store procedures
PPTX
Advance Sql Server Store procedure Presentation
PPT
Oracle-L11 using Oracle flashback technology-Mazenet solution
PDF
Overview of Oracle database12c for developers
PPTX
Oracle Data redaction - GUOB - OTN TOUR LA - 2015
PPTX
Oracle flashback
PPTX
Sql storeprocedure
PPTX
Oracle Data Redaction
PPT
Less08 Schema
PDF
12c SQL Plan Directives
PPT
Less17 Util
PDF
Test Dml With Nologging
 
DOC
Plsql
PPT
05 Creating Stored Procedures
PPTX
5. stored procedure and functions
Oracle Data Redaction - UKOUG - TECH14
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
Oracle Database 12.1.0.2 New Features
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expre...
Store procedures
Advance Sql Server Store procedure Presentation
Oracle-L11 using Oracle flashback technology-Mazenet solution
Overview of Oracle database12c for developers
Oracle Data redaction - GUOB - OTN TOUR LA - 2015
Oracle flashback
Sql storeprocedure
Oracle Data Redaction
Less08 Schema
12c SQL Plan Directives
Less17 Util
Test Dml With Nologging
 
Plsql
05 Creating Stored Procedures
5. stored procedure and functions
Ad

Similar to Tony Jambu (obscure) tools of the trade for tuning oracle sq ls (20)

PPTX
Watch Re-runs on your SQL Server with RML Utilities
PPTX
DBA Commands and Concepts That Every Developer Should Know - Part 2
PPTX
DBA Commands and Concepts That Every Developer Should Know - Part 2
PPTX
3130703_DBMS_GTU_Study_Material_Presentations_Unit-10_17102019083650AM.pptx
PDF
Oracle SQL Tuning
PPTX
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
PDF
Sherlock holmes for dba’s
PDF
Performance tuning a quick intoduction
PDF
Usertracing
PPS
Procedures/functions of rdbms
PPTX
PLSQL.pptxokokokoo9oooodjdjfjfjfjrjejrjrrjrj
PPT
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
PPTX
Sql and PL/SQL Best Practices I
PPT
SQL Optimization With Trace Data And Dbms Xplan V6
PPTX
Unit 3
PPTX
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
PPTX
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
ODP
SQL Tunning
PPT
Sql tuning guideline
PPT
Less04 Instance
Watch Re-runs on your SQL Server with RML Utilities
DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2
3130703_DBMS_GTU_Study_Material_Presentations_Unit-10_17102019083650AM.pptx
Oracle SQL Tuning
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
Sherlock holmes for dba’s
Performance tuning a quick intoduction
Usertracing
Procedures/functions of rdbms
PLSQL.pptxokokokoo9oooodjdjfjfjfjrjejrjrrjrj
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
Sql and PL/SQL Best Practices I
SQL Optimization With Trace Data And Dbms Xplan V6
Unit 3
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
SQL Tunning
Sql tuning guideline
Less04 Instance
Ad

More from InSync Conference (20)

PDF
Frank munz oracle fusion middleware and aws cloud services in sync11
PDF
Pythian MySQL - database for the web based economy
PPT
IBM and Oracle Joint Solution Centre
PDF
In Sync Running Apps On Oracle
PPTX
P6 analytics
PDF
Upk presentation insync
PPT
Oracle Fusion Middleware for JD Edwards
PPT
In sync10 grc_suite
PDF
In sync10 cliffgodwin-ebs-final
PDF
In sync10 cliffgodwin-appskeynote-final
PDF
Mnod linsync10 oba
PDF
D linsync10 ofa5yrs
PDF
D linsync10 fusaapps
PPT
Optim Insync10 Paul Griffin presentation
PPT
Nswh Insync 2010 Ammar Customer Presentation
PPT
Insync10 IBM JDE Sol Ed Announcement
PPTX
InSync10 Implement JDE Financial Analytics and Make Better Decisions
POT
Life after upgrading to r12
PDF
Ebs operational reporting at santos evaluation, selection & implementation
Frank munz oracle fusion middleware and aws cloud services in sync11
Pythian MySQL - database for the web based economy
IBM and Oracle Joint Solution Centre
In Sync Running Apps On Oracle
P6 analytics
Upk presentation insync
Oracle Fusion Middleware for JD Edwards
In sync10 grc_suite
In sync10 cliffgodwin-ebs-final
In sync10 cliffgodwin-appskeynote-final
Mnod linsync10 oba
D linsync10 ofa5yrs
D linsync10 fusaapps
Optim Insync10 Paul Griffin presentation
Nswh Insync 2010 Ammar Customer Presentation
Insync10 IBM JDE Sol Ed Announcement
InSync10 Implement JDE Financial Analytics and Make Better Decisions
Life after upgrading to r12
Ebs operational reporting at santos evaluation, selection & implementation

Recently uploaded (20)

PPTX
MYSQL Presentation for SQL database connectivity
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
cuic standard and advanced reporting.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Empathic Computing: Creating Shared Understanding
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Cloud computing and distributed systems.
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Understanding_Digital_Forensics_Presentation.pptx
MYSQL Presentation for SQL database connectivity
NewMind AI Monthly Chronicles - July 2025
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Chapter 3 Spatial Domain Image Processing.pdf
Machine learning based COVID-19 study performance prediction
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
The AUB Centre for AI in Media Proposal.docx
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Review of recent advances in non-invasive hemoglobin estimation
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
cuic standard and advanced reporting.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Empathic Computing: Creating Shared Understanding
Advanced methodologies resolving dimensionality complications for autism neur...
Cloud computing and distributed systems.
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Understanding_Digital_Forensics_Presentation.pptx

Tony Jambu (obscure) tools of the trade for tuning oracle sq ls

  • 1. (Obscure) Tools of the Trade for Tuning Oracle SQLs [email_address] Tony Jambu Melbourne, Australia
  • 2. Agenda Tuning Methodology Generating Explain Plan & Tracing TRCSESS DBMS_XPLAN SQL*Plus and Autotrace TRCANLZR - Trace Analyzer SQLT - SQLTXPLAIN Oracle Active Report Other Tools
  • 3. Tuning Methodology Where do you start? In development or production? Do you have the volume of data? Proactive or Reactive ? Explain Plans only or database tracing? Explain Plan: Quick but is ‘best guess’ Need to validate changes
  • 4. Tuning Methodology Tracing: Numerous methods to trace Produces raw data from the execution Not practical for some very large data warehouse SQLs How At own session , other sessions or database level? Numerous ways of turning tracing on
  • 5. Tracing Various methods Init.ora parameters alter session set event….. eg 10046, 10053, alter [session|system] set sql_trace=true; dbms_session.set_sql_trace(true), dbms_system.set_bool_param_in_session(...), dbms_system.set_sql_trace_in_session(...), dbms_support.start_trace, dbms_support.start_trace_in_session(...), dbms_system.set_ev(…), ***dbms_monitor.* - Oracle 10g and up. Replaces DBMS_SUPPORT oradebug session_event …
  • 6. Tracing Add name identifier to trace file alter session set tracefile_identifier ='MyTrc_'; Session Information are useful for end-to-end tracing and can be set with Machine : The name of your machine Module : The application module name Action : What you are doing eg ‘Before Transforming data’ or ‘Aggregating base data’ Service : The service name Client ID : Either logon id or set with dbms_session.set_identifier(‘A Name’) – Case sensitive
  • 7. Tracing Trace Enabling New : DBMS_MONITOR.CLIENT_ID_ TRACE _ENABLE('account_update') Means, auto enable tracing for all sessions with the identifier ‘account_update’ To disable: DBMS_MONITOR.CLIENT_ID_ TRACE _DISABLE('account_update');
  • 8. Tracing Statistics Enabling New : DBMS_MONITOR.CLIENT_ID_ STAT _ENABLE('account_update') Enable stats gathering for Client_ID = ‘account_update’ To disable: DBMS_MONITOR.CLIENT_ID_ STAT _DISABLE('account_update'); Also possible for Service, Module & Action DBMS_MONITOR.SERV_MOD_ACT_STAT_DISABLE( service_name => 'ACCTG', module_name => 'GLEDGER', action_name => 'INSERT ITEM'); *** 10g
  • 9. TRCSESS Tkprof Only works with one file at a time How to handle multiple files like PX files? trcsess Oracle utility that aggregates/consolidates and format numerous trace files into a single file Trcsess output= output_file_name ] [session= session_id ] [clientid= client_id ] [service= service_name ] [action= action_name ] [module= module_name ] [ trace_files ]
  • 10. SQL&Plus and AUTOTRACE An SQL*Plus command Usage: set autot[race] {off | on | trace[only]} [exp[lain]] [stat[istics]] ON – returns results Traceonly – Do not return results Exp – Shows execution plan Stat – Gathers execution stats
  • 11. SQL&Plus and AUTOTRACE set autotrace on : Shows the execution plan as well as statistics of the statement. set autotrace on explain: Displays the execution plan only. set autotrace on statistics : Displays the statistics only. set autotrace traceonly : Displays the execution plan and the statistics (as set autotrace on does), but doesn't print a query's result. set autotrace off : Disables all autotrace
  • 12. SQL&Plus and AUTOTRACE Pre-requisite: PLAN_TABLE. Be careful that you have your own copy of the plan_table and is the latest version in $ORACLE_HOME/rdbms/admin/utlxplan.sql In 11g, no need as there is a public Synonym to SYS.PLAN_TABLE$ . Pre-requisite: PLUSTRACE Role Users will require the PLUSTRACE role ($ORACLE_HOME/sqlplus/admin/plustrce.sql)
  • 13. SQL&Plus and AUTOTRACE DEMO_1 (not for dba) cd Trace Analyzer sqlplus tjambu/tjambu set autotrace trace exp @TJ_Test1a.sql set autotrace trace exp STAT @TJ_Test1a.sql -See diff between ON and STATS
  • 14. DBMS_XPLAN DBMS_XPLAN is an explain plan formatter Has 4 Procedures DISPLAY – Displays the explain plan from the Plan Table DISPLAY_CURSOR – Displays the Execution plan of a SQL in the cursor cache DISPLAY_AWR – Displays the Execution plan for a SQL_ID in the AWR DISPLAY_SQLSET – Displays the Execution plan for statement in a SQL tuning set
  • 15. DBMS_XPLAN dbms_xplan.display (Explain Plan) Usage: SELECT * FROM table(DBMS_XPLAN.DISPLAY); Usage Accepts 3 parameters Table_Name - Name of plan table, default value 'PLAN_TABLE'. Statement_ID - Statement id of the plan to be displayed, default value NULL. Format - Level of detail displayed, default value 'TYPICAL'. Also 'BASIC', 'ALL', 'SERIAL‘.
  • 16. DBMS_XPLAN DBMS_XPLAN.DISPLAY – Examples select * from table(dbms_xplan.display ('PLAN_TABLE', 'TJ2' , 'BASIC ')); select * from table(dbms_xplan.display ('PLAN_TABLE', 'TJ2' , 'SERIAL ')); select * from table(dbms_xplan.display ('PLAN_TABLE', 'TJ2' , 'TYPICAL ')); select * from table(dbms_xplan.display ('PLAN_TABLE', 'TJ2' , 'ALL ')); SELECT tf.* FROM DBA_HIST_SQLTEXT ht, table (DBMS_XPLAN. DISPLAY_AWR (ht.sql_id,null, null, 'ALL' )) tf WHERE ht.sql_text like ‘% EV_INTERMEDIATE %’;
  • 17. DBMS_XPLAN DBMS_XPLAN.DISPLAY_CURSOR ( Execution Plan) - DEMO 2 Run with and without GATHER_PLAN_STATS hint SELECT * FROM TABLE ( DBMS_XPLAN.display_cursor (NULL, NULL, 'ALLSTATS LAST +peeked_binds') ); cd DBMS_XPLAN sqlplus sh/sh @demo_dbms_xplan1.sql @demo_dbms_xplan2.sql
  • 18. TRCA - TRACE ANALYZER Tool from Oracle Support Center of Expertise Available from Metalink – Doc ID: 224270.1 Input : One or more trace file from 10046 Output : Diagnostics report in HTML and Text format. Excellent for tuning SQLS Contains information about all objects accesses and their statistics NOTE : Developers now have access to trace files on server!
  • 19. TRCA - TRACE ANALYZER Usage Only need one file ( trcanlzr.sql) to run from client 4 ways Analyzing one trace on the same system where it was generated. sqlplus user/passwd @trcanlzr file.trc Analyzing a set of related traces (PX) on the same system where they were generated. sqlplus user/passwd @trcanlzr TraceFiles.lis Analyzing one trace on a different system (target) to the one where it was generated (source). Analyzing a set of related traces (PX) on a different system (target) to where they were generated (source)
  • 20. TRCA - TRACE ANALYZER DEMO 3 Only need one SQL file to run from client cd trca/run sqlplus sh/sh @trcanlzr.sql TraceFiles.lis
  • 21. SQLT- SQLTXPLAIN Tool from Oracle Support Center of Expertise Available from Metalink – Doc ID: 215187.1 Input : Single SQL statement, SQL_ID or HASH_VALUE Output : Diagnostics report in HTML and Text format reporting on execution plans, CBO statistics, schema objects metadata, performance statistics, configuration parameters, and similar elements Can utilise Oracle Diagnostic and the Oracle Tuning Packs Understands database links
  • 22. SQLT- SQLTXPLAIN Execution – 3 Methods XPLAIN Method - smaller output, does not understand bind variables XTRACT Method - for when the SQL still resides in memory or in the Automatic Workload Repository AWR. Need SQL_ID or HASH_VALUE. XECUTE Method - provides the maximum level of detail. Executes the SQL being analyzed, then it produces a set of diagnostics files. Its major drawback is that if the SQL being analyzed takes long to execute, this method will take longer. For statements < 1hr
  • 23. SQLT- SQLTXPLAIN DEMO 4 - XPLAIN Input: Single SQL # cd sqlt # sqlplus sh/sh SQL> @run/sqltxplain.sql ../TJ_Test1.sql
  • 24. SQLT- SQLTXPLAIN DEMO 5 - XTRACT Input: SQL_ID or HASH_VALUE -- Check TOAD for SQL_ID or HASH_VALUE or -- Check trace file   cd sqlt sqlplus sh/sh SQL> @run/sqltxtract.sql 2751883218   hv =2751883218 ad='92da13d4' sqlid ='5y7bskyk0ctyk‘ @run/sqltxtract.sql 2751883218 Or @run/sqltxtract.sql 5y7bskyk0ctyk
  • 25. SQLT- SQLTXPLAIN DEMO 6 - XECUTE Input: Single SQL statement cd sqlt sqlplus sh/sh SQL> @run/ sqltxecute.sql ../TJ_Test1.sql
  • 26. Oracle Active Report- Real-Time SQL Monitoring New in 11gR2 EM function via DBMS_SQLTUNE Extract session/SQL information and presents infomation in GUI/Adobe Flash Needs internet connection Good for database support. Able to capture and encapsulate all the information in one HTML report. dbms_sqltune. report_sql_detail dbms_sqltune. report_sql_monitor .
  • 27. Oracle Active Report- Real-Time SQL Monitoring DEMO 7 cd “Active Report” sqlplus tjambu/tjambu SQL> @ report_sql_monitor.sql SQL> @ report_sql_detail.sql
  • 28. Other Tools - TOAD TOAD functionalities Explain Plan customisation Explain Plan comparison Trace file browser Tkprof utility
  • 29. Summary There are different approaches to SQL tuning We covered some less known tools Which to choose depends on your particular situation Do try out some of the newer tools For feedback & discussion: [email_address]
  • 30. xxxxxxx XXX Xxx XXX XXX
  • 31. Texas Memory Systems , http://www.superssd.com/whitepapers.htm http://www.texmemsys.com/files/whitepaper_opera.pdf Anand Tech, http://anandtech.com/storage/showdoc.aspx?i=3631 http://www.anandtech.com/storage/showdoc.aspx?i=3531&p=1 StorageSearch.com/SolidData, http://www.storagesearch.com/soliddata-art2-comparisons.pdf References & Acknowledgement
  • 32. Session: 715  Title: Understanding Solid State Drives (SSD) Technology for Databases, Presenter: Tony Jambu For feedback & discussion: [email_address] Please fill in the evaluation form. What did we do to reduce the End of Fin year processing from 2days to 4 hours? ANSWER Select Star Mailing list http://groups.yahoo.com/group/Select_Star/ or email [email_address]
  • 33.  

Editor's Notes

  • #3: Who attended last years presentation?