SELECT sql_id, plan_hash_value, executions Exes,
to_char(plan_time, 'YYYY-MM-DD/HH24:MI:SS') plan_time, round(elapsed_time_total/executions)
elapsed, round(cpu_time_total/executions) cputime, round(buffer_gets_total/executions)
LgRd, round(disk_reads_total/executions) PhyRd
--direct_writes_total/executions direct_writes
---(SELECT
--other_xml
---FROM dba_hist_sql_plan P WHERE P.dbid = S.dbid AND rownum = 1 AND P.plan_hash_value = S.plan_hash_value
---AND P.id = 1 AND P.sql_id = '&&sql_id') other_xml
FROM (
SELECT sql_id,
plan_hash_value, dbid, sum(CPU_TIME) AS cpu_time_total, sum(BUFFER_GETS) AS buffer_gets_total, sum(DISK_READS) AS disk_reads_total, sum(DIRECT_WRITES) AS direct_writes_total, sum(ROWS_PROCESSED) AS rows_processed_total, sum(FETCHES) AS fetches_total, sum(EXECUTIONS) AS executions, sum(ELAPSED_TIME) AS elapsed_time_total, max(plan_time) plan_time
FROM (
SELECT sql_id, s.dbid,
fetches_delta as FETCHES, decode(executions_delta,0,1,executions_delta) as EXECUTIONS, disk_reads_delta AS DISK_READS,
direct_writes_delta DIRECT_WRITES, buffer_gets_delta as
BUFFER_GETS,rows_processed_delta as ROWS_PROCESSED, cpu_time_delta as CPU_TIME, elapsed_time_delta as ELAPSED_TIME,
s.parsing_schema_name, plan_hash_value, sn.begin_interval_time as plan_time
FROM DBA_HIST_SQLSTAT s,V$DATABASE d, DBA_HIST_SNAPSHOT
sn
WHERE s.dbid = d.dbid AND bitand(nvl(s.flag, 0),
1) = 0 AND sn.end_interval_time >
(select systimestamp at TIME ZONE dbtimezone
from dual) - 7 AND s.sql_id = '&&sql_id' AND s.snap_id = sn.snap_id
) GROUP BY dbid, plan_hash_value,sql_id)
S order by 2
Sunday, June 20, 2021
awr_sql_execution_tot
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment