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

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



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

SQLHC运行时不会在数据库中创建任何对象(“数据库中不留足迹”),它只是对已有的对象提供报告和建议,可以确保它在所有系统上运行。SQLHC的脚本需要以SYSDBA或者能访问数据字典视图的用户通过SQL*Plus连接运行。SQLHC一共包含3个脚本,分别为sqlhc.sqlsqldx.sqlsqlhcxec.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)
 

 


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



 
 
 
 
 
 
 



>>



SQL Health Check


 

 


  






 



 



 





 
 




  1.  


    1.   
       

    2.  


>


downloadattachmentprocessor?parent=DOCUM

 
 
 
 
 
 
 
 






 

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

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 





SQL Health Check

  

 

 






  •  





  •  



  •  
     



  •  


  •  
       

     













  •   


     


  •  







  •  

      

     
     
  •  

  •  
     









  •  
     
     

 


  •  
     




    •  
    •  

       
    •  

       

  •  

     

  •  

     

     

     


  •  



     



     
  •  
     


  •  

     

  •  

     



     



  •  
  •  

     




  •  



     
  •  

     



 
 
 











     

img_e3029f287d989cd04bd75432ecc1c172.png
DBA笔试面试讲解
欢迎与我联系

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值