Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 How to improve SQL Performance with new Health Check Tool? Carlos Sierra Consulting Technical Advisor © 2012 Oracle Corporation – Proprietary and Confidential.

Similar presentations


Presentation on theme: "1 How to improve SQL Performance with new Health Check Tool? Carlos Sierra Consulting Technical Advisor © 2012 Oracle Corporation – Proprietary and Confidential."— Presentation transcript:

1 1 How to improve SQL Performance with new Health Check Tool? Carlos Sierra Consulting Technical Advisor © 2012 Oracle Corporation – Proprietary and Confidential

2 2 Topics What, Why, When and How? Health Checks performed What is the output? Output sample Demo Q&A © 2012 Oracle Corporation – Proprietary and Confidential

3 3 What is the SQL Health Check Tool? Small tool developed by the Server Technologies (ST) Center of Expertise (CoE) Stand-alone SQL script SQL Health Check (HC) does not install schema objects Centric to one SQL statement per use Requires to be executed connecting as SYS (or DBA) Inputs one SQL_ID Outputs HTML report with results of several Health Checks and some additional information © 2012 Oracle Corporation – Proprietary and Confidential

4 4 Why would I want to use the SQL HC? Easy way to verify environment around one SQL Does not pollute the application nor the database Executes in a few minutes Minimum resources utilization Documents “state” around one SQL Safe to use on queries or DML statements Acting upon output of relevant Health Checks may improve execution plan thus performance Output is small and easy to digest Does not require advanced SQL Tuning expertise © 2012 Oracle Corporation – Proprietary and Confidential

5 5 When should I use the SQL HC Tool? On a poorly performing SQL as per AWR or StatsPack reports On a SQL statement out of a Trace or TKPROF When a quick sanity check of the environment around one SQL is needed When using SQLTXPLAIN (SQLT) MOS 215187.1 is not a short term option When there had been recent changes on the system and a SQL has regressed in terms of performance When performance of a SQL is not consistent © 2012 Oracle Corporation – Proprietary and Confidential

6 6 How do I use the SQL HC Tool? Download latest version of sqlhc.sql out of MOS 1366133.1 Execute connected as SYS or a user with DBA privileges Parameters Does your site have Oracle Diagnostics or Oracle Tuning Pack licenses? SQL_ID for the SQL statement to be analyzed Review and digest content of HTML output report Act upon those “Observations” reported by HC Some may be more relevant than others in each case © 2012 Oracle Corporation – Proprietary and Confidential

7 7 Topics What, Why, When and How? Health Checks performed What is the output? Output sample Demo Q&A © 2012 Oracle Corporation – Proprietary and Confidential

8 8 Health Checks performed Levels Global Table Index Purpose Highlight SQL Tuning opportunities Highlight concerns © 2012 Oracle Corporation – Proprietary and Confidential

9 9 Global Health Checks Using “STATISTICS_LEVEL = ALL” on LINUX CBO parameters with non-default values optimizer_features_enable <> rdbms_version optimizer_dynamic_sampling between 1 and 3 db_file_multiblock_read_count is set nls_sort is not binary DBMS_STATS automatic gathering High version count Using first rows Fixed objects missing statistics © 2012 Oracle Corporation – Proprietary and Confidential

10 10 Global Health Checks System statistics not gathered mreadtim < sreadtim sreadtim < 2 mreadtim < 3 sreadtim > 18 mreadtim > 522 SQL with policies as per v$vpd_policy Materialized views with rewrite enabled Table with bitmap index(es) Index in plan no longer exists © 2012 Oracle Corporation – Proprietary and Confidential

11 11 Global Health Checks SQL Plan Baseline contains non-reproducible Plans Sizes of SQL Plan History and SQL Plan Baseline SQL Profile combined VPD policies Multiple CBO environments INTERNAL_FUNCTION in a Filter Predicate Plan Operations with Cost 0 and Cardinality 1 SREADTIM differs from actual db file sequential read MREADTIM differs from actual db file scattered read © 2012 Oracle Corporation – Proprietary and Confidential

12 12 Table Health Checks empty_blocks > blocks Table DOP is set Table has indexes with DOP set Index degree <> Table degree No statistics No rows Siebel small tables with statistics Small sample size Old statistics Extended statistics © 2012 Oracle Corporation – Proprietary and Confidential

13 13 Table Health Checks Columns with no statistics Columns missing low/high values Columns with old statistics More nulls than rows More distinct values than rows Zero distinct values on columns with value Incorrect NDV in long char column with histogram Frequency histograms with less buckets than NDV Frequency histogram with 1 bucket Height balanced histogram with no popular values © 2012 Oracle Corporation – Proprietary and Confidential

14 14 Table Health Checks ANALYZE command was used Average row length is 100 Tables with stale statistics SQL with policies as per dba_policies SQL with policies as per dba_audit_policies Table partitions with no statistics Table partitions where num rows = 0 Table partitions with outdated statistics Partitions with no column statistics Partition columns with outdated statistics © 2012 Oracle Corporation – Proprietary and Confidential

15 15 Table Health Checks Derived statistics in Tables or Partitions Table has locked statistics © 2012 Oracle Corporation – Proprietary and Confidential

16 16 Index Health Checks No statistics More rows in index than its table Clustering factor > rows in table Statistics on zero while columns have value Table/Index statistics out of sync ANALYZE was used No column statistics in single-column index NDV on column > num_rows in single-column index NDV is zero but column has values in single-column index © 2012 Oracle Corporation – Proprietary and Confidential

17 17 Index Health Checks NDV <> NDK in single-column index Index partitions with no statistics Index partitions where num rows = 0 Index partitions with outdated statistics Derived statistics in Index or Partitions Indexes with UNUSABLE segments INVISIBLE Indexes Index in a Plan with UNUSABLE segments Index in a Plan is now INVISIBLE © 2012 Oracle Corporation – Proprietary and Confidential

18 18 Topics What, Why, When and How? Health Checks performed What is the output? Output sample Demo Q&A © 2012 Oracle Corporation – Proprietary and Confidential

19 19 What is the output? Identification Observations (Health Checks results) SQL Text Tables Summary Indexes Summary Current SQL Statistics (GV$SQL) Historical SQL Statistics (DBA_HIST_SQLSTAT) Current Execution Plans (last execution) Current Execution Plans (all executions) Historical Execution Plans © 2012 Oracle Corporation – Proprietary and Confidential

20 20 What is the output? Tables CBO Statistics Columns CBO Statistics Indexes CBO Statistics © 2012 Oracle Corporation – Proprietary and Confidential

21 21 Observations section Global then Table then Index All observations include a verbose explanation Some observations have pointers to pertinent MOS documents Some are more relevant than others for your particular SQL Test any change before implementing in Production © 2012 Oracle Corporation – Proprietary and Confidential

22 22 Tables Summary Content Table level CBO statistics Indexes and Columns counts Columns with Histograms counts Average sample sizes for Indexes and Columns Purpose Quick quantitative view of Tables statistics health Ease a compare between two systems believed to be similar © 2012 Oracle Corporation – Proprietary and Confidential

23 23 Indexes Summary Content Index level CBO statistics Indication if Index is referenced in an Execution Plan Columns counts Columns with Histograms counts Average sample sizes for Columns Purpose Quick quantitative view of Indexes statistics health Ease a compare between two systems believed to be similar © 2012 Oracle Corporation – Proprietary and Confidential

24 24 Topics What, Why, When and How? Health Checks performed What is the output? Output sample Demo Q&A © 2012 Oracle Corporation – Proprietary and Confidential

25 25 Output sample © 2012 Oracle Corporation – Proprietary and Confidential

26 26 Output sample © 2012 Oracle Corporation – Proprietary and Confidential

27 27 Output sample © 2012 Oracle Corporation – Proprietary and Confidential

28 28 References MOS 1366133.1 SQL Tuning Health-Check Script MOS 215187.1 SQLTXPLAIN (SQLT) © 2012 Oracle Corporation – Proprietary and Confidential


Download ppt "1 How to improve SQL Performance with new Health Check Tool? Carlos Sierra Consulting Technical Advisor © 2012 Oracle Corporation – Proprietary and Confidential."

Similar presentations


Ads by Google