Dan Hotka Author/Instructor Oracle Ace Director
, LLC (c) www.danhotka.com LLC. Any reproduction or copying of this manual without the express written consent of www.danhotka.com LLC is expressly prohibited. Limitation on Warranty. THERE ARE NO WARRANTIES, EXPRESS OR IMPLIED, WITH RESPECT THERETO, INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. PURCHASER SHALL BE SOLELY RESPONSIBLE FOR THE SELECTION, USE, EFFICIENCY AND SUITABILITY OF USE OF INFORMATION CONTAINED HEREIN TO ANY PARTICULAR APPLICATION OR PROBLEM. WWW.DANHOTKA.COM LLC SHALL HAVE NO LIABILITY THEREFOR. Limitation of Liability. IN NO EVENT SHALL WWW.DANHOTKA.COM LLC BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, WITHOUT LIMITATION, ANY DAMAGES RELATINGTO LOSS OF DATA, AND ANY INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS, ARISING OUT OF OR IN ANY WAY RELATED TO YOUR USE OF THE INFORMATION CONTAINED IN THIS MANUAL. IN THE EVENT THAT THE FORGOING IS HELD UNINFORCABLE THE PARTIES AGREE THAT WWW.DANHOTKA.COM LLC'S LIABILITY TO YOU HEREUNDER, IF ANY, SHALL IN NO EVENT EXCEED THE FEE PAID BY THE INJURED PARTY FOR THE MANUAL TO WWW.DANHOTKA.COM. LLC. Dan Hotka Author/Instructor/Oracle Expert CEO DHotka@Earthlink.net 515 279 3361 Last Updated: 1/2010
Dan is a Training Consultant Dan Hotka Oracle ACE Director Oracle ACEs and Oracle ACE Directors are known for their strong credentials as Oracle community enthusiasts and advocates, with candidates nominated by anyone in the Oracle Technology and Applications communities. www.oracle.com/technology/community/oracle_ac e/index.html Oracle Authored Expert 32 Years in IT 27 years working with Oracle 12 books hundreds of articles DanHotka.Blogspot.com I also blog on TOADWorld.com Monday Lunch n Learn Short technical webinars Register for reminders Training LiveLessons Video! Safari Books Online Got a Safari Account? Take the class self-paced www.safaribooksonline.com Purchase the class http://informit.com/hotka SQL Tuning, Intro and Adv PL/SQL, OBIEE Reports and Dashboards, Oracle SQL, and Toad Show your HR or Training Department this info! Discount codes on my website Flat Fee Training for your company: 1 Course Fee Price Price includes my portable computer lab! On-site or over the Web! Portable computer lab Training Courses Include: Oracle Advanced PL/SQL Oracle SQL Tuning TOAD Courses Oracle OBIEE Reports and Dashboards Discoverer, Intro courses, Cross training!
New Book Discounts on my website Amazon.com
Lunch n Learn Schedule Feb 9 SQL Tuning: A Close Look at Advanced Explain Plans with syntax Mar 9 Oracle12 New Features PBD Management Apr 4 Oracle12 Partitioning Features Contains Release 2 updates!
DBMS_XPLAN DBMS_XPLAN Block Mode Explain Plan Documented in PL/SQL Built-in Packages
DBMS_XPLAN Select * from table( dbms_xplan.display(format=> OUTLINE )) Use explain plan for to populate plan table Should give a list of hints used to create this explain plan select plan_table_output from table(dbms_xplan.display_cursor(format=>'allstats LAST')) Put /*+ gather_plan_statistics */ into query Shows additional statistics
DBMS_XPLAN
DBMS_XPLAN
DBMS_XPLAN Hash Join Estimates Right Order Hash Join Actuals WRONG Order!
What are Explain Plans Oracle Explain Plans Visualization of the Execution Plan Which objects Oracle will use to resolve your SQL request The order that Oracle will process the steps *** Order is VERY important *** As you will learn Lots of ways to produce these Explain Plans SQL*Plus & syntax, varioius GUI tools, Oracle traces, Enterprise Manager, and more
Tuning with SQL*Plus
Using the Tools All tools use the PLAN_TABLE Oracle9i and before: <oracle_home>/rdbms/admin/utlxpl an.sql Oracle10g+ Automatically Created PLAN_TABLE$ Public Synonym to PLAN_TABLE Oracle11+ synonym has been created IF autotrace or Explan Plan For complains create public synonym under SYS
Using the Tools Various PLAN_TABLE structures Oracle10g+ - use the PLAN_TABLE$ Older Oracle s Use script in <Oracle Home>/rdbms/admin/UTLXPLAN.sql V$SQL_PLAN Library Cache Actual SQL and Explain Plans/runtime statistics Related to V$SQL view of the library cache (stats and info) Parent Cursor Related to V$SQLAREA where actual SQL stats and cursor areas are ( the data sets) Child Cursor(s)
Using the Tools AWR stores SQL and SQL explain plans 7 days worth! Use DBA_HIST_SQLTEXT to get SQL_ID and DBMS_XPLAN.Display to get Explain Plans
Using the Tools To see the bind variables V$SQL_BIND_CAPTURE Locate correct bind info using SQL_ID Important Fields: Name Position Datatype_string Value_string
Using the Tools Bind Variables Discussed Oracle11+ Adaptive Cursor Sharing SQL with bind variables Data is skewed Performs poorly then Oracle looks at Histogram on the database column associated with the bind variable Produces additional child cursors
Using the Tools Bind Variable continued TO insure quick execution every time WHEN you know the data is skewed Program in fake hints Hints don t get stripped during hard parse comments do /*+ Small */ for bind variable content with low row count /*+ Large */ for bind variable content with high row count You will have to submit one or the other based on data knowledge Maybe difficult to do but this would work
Active SQL Active SQL Shows current executing SQL! Why is my system slow? Works with any Oracle Cloud/remote/onsite No extra Oracle licensing Works great on Standard Edition Oracle Displays advanced Explain Plans Bind Variable content Oracle12 Adaptive Plans Extension of existing free SQL Tuner tool Cost Effective
10053 Trace 10053 Cost-Base Optimizer Trace Shows how Oracle arrived at Explain Plan Contains: SQL Init.ora parameters Legends (useful information) Considered Joins/Predicate processing Explain Plan Shows Outline (hints to get same explain plan) Optimizer Environment Key Statistics associated with this SQL
What have we learned? What have we learned? Useful Oracle knowledge Slides and link to this presentation Tell your friends/see you next week! Thank you! Keep in touch See you next week Remember me for your training needs