Sie sind auf Seite 1von 28

<Insert Picture Here>

How to improve SQL Performance with new Health Check Tool?


Carlos Sierra Consulting Technical Advisor
2012 Oracle Corporation Proprietary and Confidential

Topics
What, Why, When and How? Health Checks performed What is the output? Output sample Demo Q&A

2012 Oracle Corporation Proprietary and Confidential

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

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

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

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

Topics
What, Why, When and How? Health Checks performed What is the output? Output sample Demo Q&A

2012 Oracle Corporation Proprietary and Confidential

Health Checks performed


Levels
Global Table Index

Purpose
Highlight SQL Tuning opportunities Highlight concerns

2012 Oracle Corporation Proprietary and Confidential

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

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
10

2012 Oracle Corporation Proprietary and Confidential

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

11

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
12

2012 Oracle Corporation Proprietary and Confidential

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
13

2012 Oracle Corporation Proprietary and Confidential

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
14

2012 Oracle Corporation Proprietary and Confidential

Table Health Checks


Derived statistics in Tables or Partitions Table has locked statistics

2012 Oracle Corporation Proprietary and Confidential

15

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
16

2012 Oracle Corporation Proprietary and Confidential

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

17

Topics
What, Why, When and How? Health Checks performed What is the output? Output sample Demo Q&A

2012 Oracle Corporation Proprietary and Confidential

18

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
19

2012 Oracle Corporation Proprietary and Confidential

What is the output?


Tables CBO Statistics Columns CBO Statistics Indexes CBO Statistics

2012 Oracle Corporation Proprietary and Confidential

20

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

21

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

22

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

23

Topics
What, Why, When and How? Health Checks performed What is the output? Output sample Demo Q&A

2012 Oracle Corporation Proprietary and Confidential

24

Output sample

2012 Oracle Corporation Proprietary and Confidential

25

Output sample

2012 Oracle Corporation Proprietary and Confidential

26

Output sample

2012 Oracle Corporation Proprietary and Confidential

27

References
MOS 1366133.1 SQL Tuning Health-Check Script MOS 215187.1 SQLTXPLAIN (SQLT)

2012 Oracle Corporation Proprietary and Confidential

28

Das könnte Ihnen auch gefallen