- 最后登录
- 2023-8-16
- 在线时间
- 1686 小时
- 威望
- 2135
- 金钱
- 50532
- 注册时间
- 2011-10-12
- 阅读权限
- 200
- 帖子
- 5207
- 精华
- 39
- 积分
- 2135
- UID
- 2
|
2#
发表于 2012-6-18 21:55:40
可以尝试用以下脚本 追踪AWR中 SQL 的 PLAN_HASH_VALUE,若该值发生变化则说明执行计划 变化:
例如- set lines 150 pages 150
- col BEGIN_INTERVAL_TIME for a23
- col PLAN_HASH_VALUE for 9999999999
- col date_time for a30
- col snap_id heading 'SnapId'
- col executions_delta heading "No. of exec"
- col sql_profile heading "SQL|Profile" for a7
- col date_time heading 'Date time'
- col avg_lio heading 'LIO/exec' for 99999999999.99
- col avg_cputime heading 'CPUTIM/exec' for 9999999.99
- col avg_etime heading 'ETIME/exec' for 9999999.99
- col avg_pio heading 'PIO/exec' for 9999999.99
- col avg_row heading 'ROWs/exec' for 9999999.99
- SELECT distinct
- s.snap_id ,
- PLAN_HASH_VALUE,
- to_char(s.BEGIN_INTERVAL_TIME,'mm/dd/yy_hh24mi')|| to_char(s.END_INTERVAL_TIME,'_hh24mi') Date_Time,
- SQL.executions_delta,
- SQL.buffer_gets_delta/decode(nvl(SQL.executions_delta,0),0,1,SQL.executions_delta) avg_lio,
- --SQL.ccwait_delta,
- (SQL.cpu_time_delta/1000000)/decode(nvl(SQL.executions_delta,0),0,1,SQL.executions_delta) avg_cputime ,
- (SQL.elapsed_time_delta/1000000)/decode(nvl(SQL.executions_delta,0),0,1,SQL.executions_delta) avg_etime,
- SQL.DISK_READS_DELTA/decode(nvl(SQL.executions_delta,0),0,1,SQL.executions_delta) avg_pio,
- SQL.rows_processed_total/decode(nvl(SQL.executions_delta,0),0,1,SQL.executions_delta) avg_row
- --,SQL.sql_profile
- FROM
- dba_hist_sqlstat SQL,
- dba_hist_snapshot s
- WHERE
- SQL.instance_number =(select instance_number from v$instance)
- and SQL.dbid =(select dbid from v$database)
- and s.snap_id = SQL.snap_id
- AND sql_id in
- ('&SQLID') order by s.snap_id
- /
- Enter value for sqlid: bunssq950snhf
- old 21: ('&SQLID') order by s.snap_id
- new 21: ('bunssq950snhf') order by s.snap_id
- SnapId PLAN_HASH_VALUE Date time No. of exec LIO/exec CPUTIM/exec ETIME/exec PIO/exec ROWs/exec
- ---------- --------------- ------------------------------ ----------- --------------- ----------- ----------- ----------- -----------
- 1910 2694099131 06/09/12_2000_2100 1 6.00 .15 .15 .00 630.00
- 1911 2694099131 06/09/12_2100_2200 1 6.00 .15 .16 .00 637.00
- 1912 2694099131 06/09/12_2200_2300 1 6.00 .14 .14 .00 644.00
- 1913 2694099131 06/09/12_2300_0000 1 6.00 .14 .15 .00 651.00
- 1914 2694099131 06/10/12_0000_0100 1 6.00 .17 .17 .00 658.00
- 1915 2694099131 06/10/12_0100_0200 1 6.00 .14 .15 .00 665.00
- 1916 2694099131 06/10/12_0200_0300 1 36.00 .14 .14 1.00 672.00
- 1917 2694099131 06/10/12_0300_0400 1 7.00 .14 .14 .00 679.00
- 1918 2694099131 06/10/12_0400_0500 1 6.00 .14 .14 .00 686.00
- 1919 2694099131 06/10/12_0500_0600 1 6.00 .14 .14 .00 329.00
- 1920 2694099131 06/10/12_0600_0700 1 6.00 .14 .15 .00 336.00
- 1921 2694099131 06/10/12_0700_0800 1 6.00 .14 .14 .00 343.00
- 1922 2694099131 06/10/12_0800_0900 1 110.00 .15 .15 .00 350.00
- 1923 2694099131 06/10/12_0900_1000 1 8.00 .14 .14 .00 357.00
复制代码 |
|