---查找sp里面的哪条sql语句,消耗的buffer gets最多,或消耗时间最多的进行优化
select TO_CHAR(T.Begin_interval_time, 'MM-DD HH24:MI') BTIME,
s.instance_number i_n,
s.snap_id,
s.sql_id,
s.plan_hash_value,
s.EXECUTIONS_DELTA,
round(s.PX_SERVERS_EXECS_DELTA / s.EXECUTIONS_DELTA) P_PXSrv,
round(BUFFER_GETS_DELTA / executions_delta) P_gets,
round(s.DISK_READS_DELTA / s.EXECUTIONS_DELTA) P_Reads,
round(CPU_TIME_DELTA / executions_delta / 1000 / 1000) P_cpu,
round(ROWS_PROCESSED_DELTA / executions_delta) P_rows,
round(ccwait_delta / executions_delta / 1000 / 1000) P_ccwait,
round(s.ELAPSED_TIME_DELTA / s.EXECUTIONS_DELTA / 1000 / 1000) P_elptime
from dba_hist_sqlstat s, dba_hist_snapshot t
where s.snap_id = t.snap_id
and s.instance_number = t.instance_number
and s.EXECUTIONS_DELTA > 0
and s.sql_id in (select distinct sql_id from dba_hist_sqltext a where a.sql_text like '%<SP_NAME>%')
and T.Begin_interval_time > sysdate - 10
order by p_gets desc