SQL性能健康检查脚本 (SQLHC)(文档 ID 1626277.1)

2021/4/11 2:30:14

本文主要是介绍SQL性能健康检查脚本 (SQLHC)(文档 ID 1626277.1),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

SQL性能健康检查脚本 (SQLHC)(文档 ID 1626277.1)

对于SQLHC(SQL Health Check,SQL性能健康检查脚本)工具,Mos文档1626277.1有非常详细的介绍。SQLHC是Oracle Server Technologies Center of Expertise开发的一个工具。SQLHC用于检查单条SQL语句运行的环境,包括基于成本的优化器(CBO)的统计数据,用户对象的元数据定义,配置参数和其它可能影响到目标SQL性能的因素。SQLHC和SQLT工具一样,本身都是免费的,不需要任何许可证(License)。当对某一个SQL_ID运行SQLHC后,该脚本会生成一系列针对该SQL语句健康检查的一份HTML报告。SQLHC会检查的内容包括:① 待分析的单条SQL涉及的用户对象的CBO统计信息;② CBO参数;③ CBO系统统计信息;④ CBO数据字典统计信息;⑤ CBO固定对象(Fixed-Objects)统计信息。

SQLHC运行时不会在数据库中创建任何对象(“数据库中不留足迹”),它只是对已有的对象提供报告和建议,可以确保它在所有系统上运行。SQLHC的脚本需要以SYS、DBA或者能访问数据字典视图的用户通过SQL*Plus连接运行。SQLHC一共包含3个脚本,分别为sqlhc.sql、sqldx.sql和sqlhcxec.sql,其中sqlhc.sql里边会调用sqldx.sql脚本。sqlhcxec.sql是单独执行的,不过该脚本需要输入一个脚本文件作为入参,而且该脚本文件可以包含绑定变量,但是必须要有“/* ^^unique_id */”注释,可以包含其它的Hint,如下所示:

点击(此处)折叠或打开

  1. REM Sample SCRIPT to be used as input to sqltxecute.sql
  2. REM

  3. -- execute sqlt xecute as sh passing script name
  4. -- cd sqlt
  5. -- #sqlplus sh
  6. -- SQL> start run/sqltxecute.sql input/sample/script1.sql

  7. REM Optional ALTER SESSION commands
  8. REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  9. --ALTER SESSION SET statistics_level = ALL;

  10. REM Optional Binds
  11. REM ~~~~~~~~~~~~~~

  12. VAR b1 NUMBER;
  13. EXEC :b1 := 10;

  14. REM SQL statement to be executed
  15. REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  16. SELECT /*+ gather_plan_statistics monitor bind_aware */
  17.        /* ^^unique_id */
  18.        s1.channel_id,
  19.        SUM(p.prod_list_price) price
  20.   FROM products p,
  21.        sales s1,
  22.        sales s2
  23.  WHERE s1.cust_id = :b1
  24.    AND s1.prod_id = p.prod_id
  25.    AND s1.time_id = s2.time_id
  26.  GROUP BY
  27.        s1.channel_id;
  28. /
  29. /

  30. REM Notes:
  31. REM 1. SQL must contain token: /* ^^unique_id */
  32. REM 2. Do not replace ^^unique_id with your own tag.
  33. REM 3. SQL may contain CBO Hints, like:
  34. REM /*+ gather_plan_statistics monitor bind_aware */


sqlhcxec  .  sql:  

点击(此处)折叠或打开

  1. REM EXAMPLE
  2. REM # sqlplus / as sysdba
  3. REM SQL> START [path]sqlhcxec.sql [T|D|N] [path]scriptname
  4. REM SQL> START utl/sqlhcxec.sql T input/sample/script1.sql


sqlhc.sql:

点击(此处)折叠或打开

  1. REM PARAMETERS
  2. REM 1. Oracle Pack license (Tuning or Diagnostics or None) T|D|N
  3. REM 2. SQL_ID of interest.
  4. REM
  5. REM EXECUTION
  6. REM 1. Start SQL*Plus connecting as SYS or user with DBA role or
  7. REM user with access to data dictionary views.
  8. REM 2. Execute script sqlhc.sql passing values for parameters.
  9. REM
  10. REM EXAMPLE
  11. REM # sqlplus / as sysdba
  12. REM SQL> START [path]sqlhc.sql [T|D|N] [SQL_ID]
  13. REM SQL> START sqlhc.sql T 51x6yr9ym5hdc









SQL 性能健康检查脚本 (SQLHC) (文档 ID 1626277.1)
         

文档详细信息

     


通过电子邮件发送此文档的链接在新窗口中打开文档可打印页

类型: 状态: 上次主更新: 上次更新: 语言:

SCRIPT PUBLISHED 2015-6-23 2016-9-16 English简体中文日本語???

 

  



文档内容  



用途
 下载 SQL Tuning Health-Check Script
 什么是 SQL Tuning Health-Check Script? (SQLHC)
 Licensing (SQLHC本身是免费的,不需要任何license)
 SQLHC总体概述
 最佳实践
 主动预防问题和诊断信息收集
 问题咨询,获取帮助,分享您对此文章的经验

要求

配置

说明

Script

示例输出

参考


适用于:

Oracle Database - Enterprise Edition - 版本 10.2.0.1 和更高版本  
Oracle Database Products > Oracle Database Suite > Oracle Database  
Oracle Database - Standard Edition - 版本 10.2.0.1 和更高版本  
Oracle Database - Personal Edition - 版本 10.2.0.1 和更高版本  
本文档所含信息适用于所有平台  

用途

 

下载 SQL Tuning Health-Check Script

SQL Health Check

在这里下载 SQLHC Script。


 

什么是 SQL Tuning Health-Check Script? (SQLHC)

SQL Tuning Health-Check Script 是 Oracle Server Technologies Center of Expertise 开发的一个工具。该工具也被称为 SQLHC,用于检查单条 SQL 语句运行的环境,包括基于成本的优化器(CBO)的统计数据,用户对象的元数据定义,配置参数和其他可能影响到待分析 SQL 性能的因素。

 

Licensing (SQLHC本身是免费的,不需要任何license)

就像上面提到的,SQLHC本身是免费的,不需要任何license. 
如果Diagnostic或者Tuning pack已经安装了, SQLHC会收集AWR中的信息,因此它会询问是否Diagnostic或者Tuning pack已经获得了license. 关于更详细的信息,请参照SQLHC FAQ的 licensing 部分:

Document 1454160.1 FAQ: SQL Health Check (SQLHC) Frequently Asked Questions


 

SQLHC总体概述

如下是一个对 SQLHC 总体概述的视频资料:

Document 1455583.1 SQL Tuning Health-Check Script (SQLHC) Video


SQLHC 的初衷是通过确保某一个 SQL 的运行环境合理,从而帮助用户规避一些可避免的 SQL 性能问题。

SQLHC 运行时不会在数据库中创建任何对象(“数据库中不留足迹”),确保它可以在所有系统上运行。

当对某一个 SQL_ID 运行 SQLHC 后,该脚本会生成一系列针对该 SQL 语句健康检查的一份 HTML 报告。您可以通过 AWR/ASH 或者查询 V$SQL 得到 SQL 语句的 SQL_ID:

Document 1627387.1 How to Determine the SQL_ID for a SQL Statement

健康检查会在如下方面执行:

  • 待分析的单条 SQL 涉及的用户对象的 CBO 统计信息
  • CBO 参数
  • CBO 系统统计信息
  • CBO 数据字典统计信息
  • CBO Fixed-objects 统计信息

注意:您可以在如下地址找到一篇题为"How to Improve SQL Performance with the New Health Check Tool?"的视频录像,以及一些其他的视频录像:  

Document 740964.1 Advisor Webcast Archived Recordings


您可以在如下地址找到 SQL Healthcheck script 的 FAQ:  

Document 1417774.1 FAQ: SQLHC HealthCheck Frequently Asked Questions


此外,我们欢迎您提出更多的健康检查建议。  
如果您需要一些特殊的健康检查但是在 SQLHC 中没有包含,只要该健康检查可以通过一条 SQL 命令实现(数据库中不留足迹),那么我们可以考虑在今后的版本中实现。  

如果有需要补充的内容,请在此文章中添加评论。


 

最佳实践

 

主动预防问题和诊断信息收集

尽管一些问题是不可预料的,在很多时候,如果迹象发现及时,这些问题是可以避免的。另外,如果问题真的发生了,事后收集该问题的信息是没有用的。SQLHC 是一种技术支持推荐的收集这些信息的工具。关于使用建议,其他的前提准备和诊断,参考:

Document 1482811.1 Best Practices: Proactively Avoiding Database and Query Performance Issues  
Document 1477599.1 Best Practices Around Data Collection For Performance Issues

 

问题咨询,获取帮助,分享您对此文章的经验

您想和其他 Oracle 客户,Oracle 雇员和行业专家来进一步探讨该主题么?

请点击这里加入讨论,您可以咨询问题,获得其他人的帮助,分享您对这边文章的经验。
点击这里访问 My Oracle Support Community 数据库调优主页来发现对其他文章和主题的讨论

要求

以 SYS, DBA 或者能访问数据字典视图的用户通过 SQL*Plus 连接运行此脚本。

注意:该脚本不会在数据库中创建任何对象,它只是对已有的对象提供报告和建议。

配置

不需要任何配置。

说明

  1. 登录数据库服务器并且设置数据库实例环境变量
  2. 下载 "sqlhc.zip" 并解压到一个合适的目录
  3. 以 SYS, DBA 或者能访问数据字典视图的用户通过 SQL*Plus 连接并执行该脚本,需要输入两个参数

    1. Oracle Pack License (Tuning, Diagnostics or None) [T|D|N] (required)
      如果有 Tuning and Diagnostics licenses 那么输入 T(指 Oracle Tuning pack,包括 Oracle Diagnostics)

    2. 待分析的 SQL 的有效 SQL_ID 

例如:

# sqlplus / as sysdba  
SQL> START sqlhc.sql T djkbyr8vkc64h


警告

此示例代码只为教育目的,Oracle Support不提供技术支持。它已经过内部测试,然而我们无法确保它在任何环境中都能成功使用。请您在使用之前先在测试环境中运行。  

SCRIPT

在这里下载 SQLHC Script。

示例输出

downloadattachmentprocessor?parent=DOCUMENT&sourceId=1626277.1&attachid=1366133.1:SQLHC_Example1&clickstream=yes

参考

NOTE:1460440.1   - Script PXHCDR.SQL: Parallel Execution Health-Checks and Diagnostics Reports  
NOTE:1417774.1   - FAQ: SQL Health Check (SQLHC) Frequently Asked Questions  
NOTE:224270.1   - TRCANLZR (TRCA): SQL_TRACE/Event 10046 Trace File Analyzer - Tool for Interpreting Raw SQL Traces  
NOTE:1477599.1   - Best Practices: Proactive Data Collection for Performance Issues  
NOTE:1455583.1   - SQL Tuning Health-Check Script (SQLHC) Video  
NOTE:215187.1   - SQLT Diagnostic Tool  
NOTE:243755.1   - Script to produce HTML report with top consumers out of PL/SQL Profiler DBMS_PROFILER data  
NOTE:1482811.1   - Best Practices: Proactively Avoiding Database and Query Performance Issues  




FAQ: SQL Health Check (SQLHC) Frequently Asked Questions (文档 ID 1417774.1)  

 文档详细信息 

通过电子邮件发送此文档的链接在新窗口中打开文档可打印页

类型: 状态: 上次主更新: 上次更新:

FAQPUBLISHED2016-11-32016-11-3


In this Document


Purpose

Questions and Answers
 Background and Structure
 What is the SQL Tuning Health-Check Script?
 What is the origin of SQLHC?
 Is SQLHC an 'advanced' version of SQLTXPLAIN?
 Are the underlying selects used by SQLHC available?
 Setup and Usage
 Where can SQLHC be downloaded from?
 How can I identify the SQL I want to Healthcheck?
 Does SQLHC have to execute the SQL to generate a report?
 What if the SQL_ID in question has been aged out from memory?
 Can SQLHC retrieve an explain plan from memory or the AWR?
 Is SQLHC safe to use in a production environment?
 Is SQLHC practical to use for complex sql statements?
 Part of the sqlhc.sql script that inserts rows into the plan_table, but the documentation states that SQLHC Leaves "no database footprint". How can this be the case?
 The SQLHC Documentation states that there is no configuration required, but it does not state how to create the 'plan_table'. How can I create the plan_table?
 Compatible Versions and licensing
 Is the SQLHC script the same for all versions?
 Can SQLHC be used on Oracle 9i or below?
 What is the licensing requirement for SQLHC?
 What is missing from the report if the Tuning Pack is not installed?
 When using SQLHC, is it more beneficial to have AWR than not having AWR?
 Are the global health checks specific to any version of Oracle?
 Software Compatibility
 Does SQLHC work with --Insert application here--
 Are there any limitations on using this script in a Database running EBusiness Suite?
 Is it practical to use this tool for SAP?
 Does this SQL Health Check tool take into consideration that the query is executed on an Exadata system/database ?
 Are there any Exadata specific settings?
 Can this tool be used with Data Guard?
 How we can integrate this script in to GridControl?
 Are there specific checks related to Peoplesoft?
 Are there specific checks related to Siebel?
 Compatibility with Specific Database Features
 Can SQLHC be used on a remote database?
 Can SQLHC be used on SQL that accesses a remote database?
 Does SQLHC work with XML Type and XML indexes?
 Does it work with encrypted columns?
 Does SQLHC work with LOB columns?
 Does SQLHC advise for extended statistic or index reordering?
 Is SQLHC RAC aware?
 Can I use SQLHC to analyze a call to a pl/sql procedure?
 Is there a way to run without having to execute the SQL (like EXPLAIN PLAN?)
 Does SQLHC show multiple plans from the SQL Tuning Advisor?
 What is the difference between SQLHC and --Insert application here--
 How does SQLHC differ from SQLT?
 What is the difference between SQLHC and AWR and TKProf?
 Checks related to Statistics
 SQLHC mentions some issues with system statistics. Are system statistics supposed to be gathered?
 Are statistics on dictionary objects supposed to be gathered?
 Are statistics required on temporary tables?
 Can the tool determine whether statistics were gathered using ANALYZE instead of DBMS_STATS
 Since 11g Oracle automates the statistics collection, why is the script checking for statistics health?
 Does SQLHC use just the most recent statistics for health check?
 If the statistics have been locked, then will SQLHC give the desired results?
 Questions regarding specific checks performed
 SQLHC says that Value A is greater than Value B. This is impossible. How can this have occurred?
 If a collective parameter such as "OPTIMIZER_FEATURES_ENABLE" has been set, does SQLHC just report on that parameter change or on all the affected underlying parameters?
 Miscellaneous Questions
 Does SQLHC show all the checks done or just the results that are non-compliant?
 Is the "Tables" and "Indexes Summary" for all tables or only for the tables affected by a particular SQL?
 Does SQLHC check the dictionary statistics against the actual values in the objects?
 Does the health check account for bind variables in any way?
 Will SQLHC tell you that the same SQL is used with different plans ?
 Can the health check script help me identify changes to the explain plan over a long period of time?
 Does SQLHC provide any advise to improve the performance or is it just a health check?
 Does SQLT provide SQL recommendations or does it only Provide the Execution plan?
 Is SQLHC able to identify disk I/O performance issues?
 How is it best to use the information provided by SQLHC?
 Does SQLHC take into account session parameter changes as well as global ones?
 Could SQLHC not be integrated with advisor tools rather than having multiple tools?

References


APPLIES TO:

Oracle Database - Enterprise Edition - Version 10.1.0.2 to 11.2.0.3 [Release 10.1 to 11.2]  
Information in this document applies to any platform.  

PURPOSE

SQL Health Check

This document answers some of the frequently asked questions about the SQLHC tool.

NOTE: We welcome any additional health-checks that you may suggest. If any specific health-checks are needed and not covered by this script, then as long as the health-check can be produced with a SQL Command (leaving no database footprint ) then these can be implemented in future versions.  

Please add comments to this Document or to:   

Document 1366133.1 SQL Tuning Health-Check Script (SQLHC)


for any desired additions.


QUESTIONS AND ANSWERS

 

Background and Structure

  • What is the SQL Tuning Health-Check Script?

    The SQL Tuning Health-Check Script is a tool developed by the Oracle Server Technologies Center of Expertise. The tool, also known as SQLHC, is used to check the environment in which a single SQL Statement runs, checking checks Cost-based Optimizer (CBO) statistics, schema object metadata, configuration parameters and other elements that may influence the performance of the one SQL being analyzed.

    An overview video about SQLHC is available here :

    Document 1455583.1 SQL Tuning Health-Check Script (SQLHC) Video


    The intention of SQLHC is to allow users to avoid SQL Performance from being affected by avoidable problems by ensuring that the environment that an individual SQL runs in is sound.

    It does this while leaving "no database footprint" ensuring it can be run on all systems.
  • What is the origin of SQLHC?

    SQLHC is a subset of the SQL used by the SQLTXPLAIN script:

    Document 215187.1 SQLT (SQLTXPLAIN) - Tool That Helps To Diagnose SQL Statements Performing Poorly


    but unlike that tool, has no database footprint.

    It is a relatively short SQL script that generates a HTML output. It extracts database statistic information using selects or standard APIs (such as DBMS_XPLAN) from the database and combines that with Automatic Workload Repository (AWR) output if the correct licenses are available.
  • Is SQLHC an 'advanced' version of SQLTXPLAIN?

    Quite the opposite. SQLT is far more advanced than SQLHC; while it incorporates similar checks to those done in SQLHC it is far more extensive generally. SQLHC is simply a quick health check for a statement. See: 

    Document 215187.1 SQLT (SQLTXPLAIN) - Tool That Helps To Diagnose SQL Statements Performing Poorly

  • Are the underlying selects used by SQLHC available?

    SQLHC is simply a SQL script. The source code is clear in the sqlhc.sql script

 

Setup and Usage

  • Where can SQLHC be downloaded from?

    See the following article for details:

    Document 1366133.1 SQL Tuning Health-Check Script (SQLHC)

  • How can I identify the SQL I want to Healthcheck?

    SQLHC uses the SQL_ID of the desired statement to generate the Health check report. You can take the SQL_ID from an AWR or ASH report or you can select it from the database. If you are able to identify the SQL with a particular identifiable string or by some kind of unique comment such as: /* TARGET SQL */ then this will make it easier to locate. For example:

    SELECT /* TARGET SQL */ * FROM dual;
    
    SELECT sql_id, substr(sql_text,1,40) sql_text  
    FROM  v$sql 
    WHERE sql_text like 'SELECT /* TARGET SQL */%'
    
    SQL_ID        SQL_TEXT
    ------------- ----------------------------------------
    0xzhrtn5gkpjs SELECT /* TARGET SQL */ * FROM dual

    Please also refer to the following document for more examples:

    Document 1627387.1 How to Determine the SQL_ID for a SQL Statement

  • Does SQLHC have to execute the SQL to generate a report?

    No.
    SQLHC uses the SQL_ID of a statement that has already been executed and is in memory to generate the report. It can also retrieve information on the statement from the Automatic Workload Repository (AWR) if the correct licenses are available.
  • What if the SQL_ID in question has been aged out from memory?

    In that case the SQL would have to be re-executed because this tool is dependent upon having a current SQL_ID. Historical information could then be extracted from AWR.
  • Can SQLHC retrieve an explain plan from memory or the AWR?

    Yes.
    SQLHC will access both using the SQL_ID provided, assuming you have indicated that you have the appropriate licenses.
  • Is SQLHC safe to use in a production environment?

    Yes.
    It has a very very small resource requirement and performs a rollback at the end of the script so that no changes are made.
  • Is SQLHC practical to use for complex sql statements?

    Yes.
    SQLHC is a good, fast way to check your SQL independent of the size of the SQL or the Application you are using.
  • Part of the sqlhc.sql script that inserts rows into the plan_table, but the documentation states that SQLHC Leaves "no database footprint". How can this be the case?

    The SQLHC script performs a rollback at the end. Any additions made to the plan table (or any other object) are removed at the end of the script and the original state restored.
  • The SQLHC Documentation states that there is no configuration required, but it does not state how to create the 'plan_table'. How can I create the plan_table?

    On most databases, the plan table is pre-created centrally and referenced by a public synonym using the 'catplan.sql' script from $ORACLE_HOME/rdbms/admin. If it is not there or accessible then you should check your installation logs for issues.

 

Compatible Versions and licensing

  • Is the SQLHC script the same for all versions?

    Yes. The script is identical
  • Can SQLHC be used on Oracle 9i or below?

    No.
    SQLHC was designed to work on 10g and above.
    It will not work on 9i or below because it uses SQL_ID to identify the SQL and this is not available in 9i or below.
  • What is the licensing requirement for SQLHC?

    SQLHC requires no license and is FREE.
    Since SQLHC can use information from AWR reports if the Diagnostic or Tuning pack are installed, it asks if these packs are licensed at your site.

    If they are licensed, then answer "Yes" to this question to perform additional checks.
    If they are not licensed then Answer "No".

    You should check with your site license manager if you have doubts regarding the licensing arrangements with regard to Oracle packs.
    SQLHC does NOT check for a valid license
  • What is missing from the report if the Tuning Pack is not installed?

    SQLHC uses packs to give it access to AWR (Automatic Workload Repository) based information  (AWR information is accessible via the Diagnostic pack; the Tuning pack is a superset of the Diagnostic pack so either will provide access to this information). The AWR infrastructure is installed by default (because the database uses AWR information for internal purposes), the real question is whether you are licensed to use it or not. 

    Report sections that use AWR information are annotated with a 'captured by AWR' key phrase.
    These sections currently include: "Indexes Summary",  "Historical SQL Statistics (DBA_HIST_SQLSTAT)" and "Historical Execution Plans",

    If AWR information is not made available by the presence of a license for one of the aforementioned packs, used then the AWR related information in these sections will not be reported.
  • When using SQLHC, is it more beneficial to have AWR than not having AWR?

    Yes.
    AWR information is a component of the diagnostic pack and is fundamental for performance diagnostics and interpretation. Generally, if you do not have AWR then you would need to use statspack but this is of limited use on later versions. 

    If you have enterprise editions it is very useful to have AWR to diagnose performance issues.
    Specifically for SQLHC, having AWR information provides more usable diagnostic output than without, so we would recommend it but it is not a pre-requisite.
  • Are the global health checks specific to any version of Oracle?

    Some of the checks (such as those introduced in a particular version e.g. automatic statistics gathering) are specific to versions. Otherwise, no, the checks are a combination of best practices and indicators of invalid information, among other things.

 

Software Compatibility

  • Does SQLHC work with --Insert application here--

    SQLHC is a simple Health Check script that uses SQL commands run against the data dictionary to produce a report. It is a good, fast way to check your SQL for issues independent of the app you are using. This means that it can work against any SELECT generated by any application software.

    We would recommend that you execute the script in SQL*Plus but you can probably execute it anywhere that can run SQL Statements.
  • Are there any limitations on using this script in a Database running EBusiness Suite?

    No.
  • Is it practical to use this tool for SAP?

    Yes.
  • Does this SQL Health Check tool take into consideration that the query is executed on an Exadata system/database ?

    No.
  • Are there any Exadata specific settings?

    Not at this time.
  • Can this tool be used with Data Guard?

    Yes.
  • How we can integrate this script in to GridControl?

    SQLHC is a simple SQL script that you run outside of Grid Control.
  • Are there specific checks related to Peoplesoft?

    Not currently.
  • Are there specific checks related to Siebel?

    Yes, there is at least one health check for Siebel included in SQLHC

 

Compatibility with Specific Database Features

  • Can SQLHC be used on a remote database?

    SQLHC assumes that you have access to the database where you want to run the health check so connecting to a remote database will work fine.
  • Can SQLHC be used on SQL that accesses a remote database?

    SQLHC assumes that you have access to the database where you want to run the health check so selects like :

    select * from table@remote_database


    will not work. With this select and selects like: 

    select * from local_table, remote_table@remote_database

      
    we suggest using SQLTXPLAIN instead of SQLHC.
    See: 

    Document 215187.1 SQLT (SQLTXPLAIN) - Tool That Helps To Diagnose SQL Statements Performing Poorly

  • Does SQLHC work with XML Type and XML indexes?

    No.
  • Does it work with encrypted columns?

    Yes. 
    When gathering statistics, DBMS_STATS does not treat these columns any differently from any others. Since SQLHC simply reports on the health and validity of the statistics on these columns it will work fine.
  • Does SQLHC work with LOB columns?

    Yes it does, but since we do not collate the same type statistics information for LOB columns as standard columns and we don't directly access these columns with standard predicates, the same output as a standard column is not provided.
  • Does SQLHC advise for extended statistic or index reordering?

    No, extended statistics and index reordering are not considered by SQLHC
  • Is SQLHC RAC aware?

    Yes, it reports on information available across the entire RAC (ie. AWR/statistics) and also that which is specific to the node (e.g. initialisation parameters etc)
  • Can I use SQLHC to analyze a call to a pl/sql procedure?

    Not with this tool. We recommend that you use SQLT for more advanced capabilities.
    See: 

    Document 215187.1 SQLT (SQLTXPLAIN) - Tool That Helps To Diagnose SQL Statements Performing Poorly

  • Is there a way to run without having to execute the SQL (like EXPLAIN PLAN?)

    For example:

    EXPLAIN PLAN FOR SELECT /* TARGET SQL */ * FROM dual;


    No.
    Currently, if you run SQLHC against the SQL_ID from an 'EXPLAIN PLAN FOR' command, it runs and completes successfully. However it does not pickup the statistics for the tables in the query, nor does it produce the current explain plan it.

    For SQLHC to retrieve information the SQL has to have been executed at sometime on the instance and the SQL data still needs to be in memory or in the Automatic Workload repository. Essentially, SQLHC creates a report by extracting existing 'historical' data about a SQL statement. It does not execute and monitor a current statement.
  • Does SQLHC show multiple plans from the SQL Tuning Advisor?

    No.
    Since SQLHC is designed as a lightweight health check it does not have the same functionality as a more comprehensive tool such as SQLTXPLAIN or SQL Tuning Advisor itself.

    If you want to include SQL Tuning Advisor in a SQL report  which includes Health Checks and much more then use SQLTXPLAIN instead (ensuring you have the appropriate license for the Advisor).
    See: 

    Document 215187.1 SQLT (SQLTXPLAIN) - Tool That Helps To Diagnose SQL Statements Performing Poorly

 

What is the difference between SQLHC and --Insert application here--

For specific details of a number of performance related database features, see:

Document 1361401.1 Where to Find Information About Performance Related Features


  • How does SQLHC differ from SQLT?

    SQLT is far more advanced than SQLHC; while it incorporates similar checks to those done in SQLHC it is far more extensive generally. SQLHC is simply a quick health check for a statement. See: 

    Document 215187.1 SQLT (SQLTXPLAIN) - Tool That Helps To Diagnose SQL Statements Performing Poorly

  • What is the difference between SQLHC and AWR and TKProf?

    SQLHC, AWR and TKProf are completely different tools for different purposes.

    • SQLHC is a FREE script to check the health of the environment as applies to a single SQL statement See:

      Document 1366133.1 SQL Tuning Health-Check Script

    • AWR is the Automatic Workload Repository and is a fundamental mechanism for the storage of general performance information in the database. Based on this stored information, reports are provided that can help diagnose and resolve issues related to the performance of the database and statements within it. See: 

      Document 1363422.1 Automatic Workload Repository (AWR) Reports - Start Point

    • TKProf is a tool that formats trace files to provide collated information about a process as recorded in that trace file. See: 

      Document 760786.1 TKProf Interpretation (9i and above)

 

Checks related to Statistics

  • SQLHC mentions some issues with system statistics. Are system statistics supposed to be gathered?

    Statistics pertaining to the actual system itself are useful so that Oracle can determine the likely load that the queries will be running in an adjust plans accordingly. See 

    Document 470316.1 Using Actual System Statistics (Collected CPU and IO information)


    for more details
  • Are statistics on dictionary objects supposed to be gathered?

    Yes. Since the cost base optimizer relies on accurate statistics it is sensible to gather statistics on all tables and maintain them. See 

    Document 457926.1 How to Gather Statistics on SYS Objects and 'Fixed' Objects?


    Alternatively Dynamic sampling can be used. See 

    Document 336267.1 Optimizer Dynamic Sampling (OPTIMIZER_DYNAMIC_SAMPLING)

  • Are statistics required on temporary tables?

    It is usually best to use dynamic sampling on Global Temporary tables, because of their volatile nature. See:

    Document 336267.1 Optimizer Dynamic Sampling (OPTIMIZER_DYNAMIC_SAMPLING)


    Alternatively you can fix their statistics to a 'general' value to preserve a particular 'acceptable' access path.

    Document 130899.1 How to Set User-Defined Statistics Instead of RDBMS Statistics


    See the following document for other suggestions :

    Document 356540.1 How to workaround issues with objects that have no statistics

  • Can the tool determine whether statistics were gathered using ANALYZE instead of DBMS_STATS

    Although the statistics collected by ANALYZE may be different to DBMS_STATS the changes may not be sufficient to positively identify the use of ANALYZE nor is there any view that identifies ANALYZE usage or otherwise. The tool will rather identify issues with the statistics validity which is likely more important than the source for plan generation assuming the statistics are correct. the ANALYZE command should not be used in version 11 only DBMS_STATS should be used to collect statistics.
  • Since 11g Oracle automates the statistics collection, why is the script checking for statistics health?

    Just because statistics collection is automated does not mean that large data loads or different collection intervals may not have changed them. We also cannot guarantee that the automated statistics have not been disabled.
  • Does SQLHC use just the most recent statistics for health check?

    Yes. SQLHC uses the statistics at the time that it is run. For a more comprehensive look at the historic statistics on objects use SQLT. See: 

    Document 215187.1 SQLT (SQLTXPLAIN) - Tool That Helps To Diagnose SQL Statements Performing Poorly

  • If the statistics have been locked, then will SQLHC give the desired results?

    Yes. SQLHC will give the same results whether the statistics are locked or not. Locking statistics does not prevent them from being invalid.

 

Questions regarding specific checks performed

  • SQLHC says that Value A is greater than Value B. This is impossible. How can this have occurred?

    SQLHC reports on what it finds in the dictionary and if it finds issues it outputs a warning. It does not necessarily comment on the origin of the problem. As for potential causes, then:and so it is possible for meaningless statistics to exist. The tool checks for such issues so that plans are not affected.
    • different statistics may have been collected at different times
    • indexes and tables may have been collected separately when row counts were different, (for example if you gathered index stats, then deleted rows from the table and then just gathered on the table then you would have a mismatch.
  • If a collective parameter such as "OPTIMIZER_FEATURES_ENABLE" has been set, does SQLHC just report on that parameter change or on all the affected underlying parameters?

    SQLHC just reports on the top level parameter change. Each parameter is handled independently of each other. Individual issues may generate more than one observation

 

Miscellaneous Questions

  • Does SQLHC show all the checks done or just the results that are non-compliant?

    SQLHC shows only the not compliant observations. All Statistics and plans are shown for the associated objects however.
  • Is the "Tables" and "Indexes Summary" for all tables or only for the tables affected by a particular SQL?

    SQLHC reports on all the tables referenced in the query you have submitted to the tool.
  • Does SQLHC check the dictionary statistics against the actual values in the objects?

    No.
    SQLHC just compares the dictionary statistics against each other and against known bets practices
  • Does the health check account for bind variables in any way?

    Yes, but for a more detailed analysis of the binds / histograms on relevant columns etc then SQLTXPLAIN will provide more details (SQLHC is designed to be very fast). See: 

    Document 215187.1 SQLT (SQLTXPLAIN) - Tool That Helps To Diagnose SQL Statements Performing Poorly

  • Will SQLHC tell you that the same SQL is used with different plans ?

    Yes.
    It will show there are multiple plans but that is not the primary function of the tool. For that you would be better to use SQLT. See: 

    Document 215187.1 SQLT (SQLTXPLAIN) - Tool That Helps To Diagnose SQL Statements Performing Poorly


    If you have an extremely large number of versions then refer to:

    Document 296377.1 Troubleshooting: High Version Count Issues

  • Can the health check script help me identify changes to the explain plan over a long period of time?

    Yes, if AWR data is used.
    With AWR, SQLHC could help in showing the plan changes from the one in memory compared to the one stored in the AWR repository. It will list all the execution plans of a query from the past (assuming they are still available in AWR)
  • Does SQLHC provide any advise to improve the performance or is it just a health check?

    SQLHC does not provide any direct advice. However as a reult of implementing the suggested changes, performance may be improved. For specific SQL Tuning Advice, you should use the SQL Tuning Advisor. See:

    Document 262687.1 How to use the Sql Tuning Advisor.

  • Does SQLT provide SQL recommendations or does it only Provide the Execution plan?

    SQLTXPLAIN provides far more than just the Execution plan. It generates a whole set of detailed information about a query and its execution and can also link to the tuning advisor to provide specific plan advice. You can download SQLTXPLAIN from: 

    Document 215187.1 SQLT (SQLTXPLAIN) - Tool That Helps To Diagnose SQL Statements Performing Poorly

  • Is SQLHC able to identify disk I/O performance issues?

    It is not currently designed to incorporate this kind of general checks. We welcome any additional health-checks that you may suggest. If any specific health-checks are needed and not covered by this script, then as long as the health-check can be produced with a SQL Command (leaving no database footprint ) then these can be implemented in future versions.
  • How is it best to use the information provided by SQLHC?

    SQLHC does a number of check on the validity of various statistics and parameters with a brief explanation of why they may be a cause for concern. Typically you would be running SQLHC because you are concerned about the performance of a particular SQL statement. Since invalid or ill-advised setting may cause the optimizer to pick a sub-optimal access path it makes sense to rectify any potential problems found by the health check.

    So, review the findings, assess their potential impact on the statement in question and implement fixes as appropriate. The following article provides a link to a large amount of back ground knowledge:

    Document 199083.1 * Master Note: SQL Query Performance Overview


    Additionally, questions can be discussed with the MOS Database Tuning Community Members:

    Document 1383594.1 Collaborate With MOS Database Tuning Community Members

  • Does SQLHC take into account session parameter changes as well as global ones?

    Yes.
  • Could SQLHC not be integrated with advisor tools rather than having multiple tools?

    SQLHC was deliberately created from SQLT so as to provide a very lightweight initial check. If you want a more comprehensive report then use SQLT. See: 

    Document 215187.1 SQLT (SQLTXPLAIN) - Tool That Helps To Diagnose SQL Statements Performing Poorly



REFERENCES


NOTE:1366133.1   - SQL Tuning Health-Check Script (SQLHC)  
NOTE:1455583.1   - SQL Tuning Health-Check Script (SQLHC) Video  
NOTE:1627387.1   - How to Determine the SQL_ID for a SQL Statement  




这篇关于SQL性能健康检查脚本 (SQLHC)(文档 ID 1626277.1)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程