Recently I used the following SQL query to find out the costly SQLs in 10g.
There is no baseline used here to decide which sql is costly, but I considered the SQLs with cost more than 10000 as costly.
select
sql_id,
(select sql_text from dba_hist_sqltext where sql_id=dhsp.sql_id) sql_text,
cost,
cardinality,
bytes,
cpu_cost,
io_cost,
time,
temp_space,
other_xml
from dba_hist_sql_plan dhsp where timestamp > trunc(sysdate) -7
and depth=1
and cost > 10000
order by cost desc
Above SQL returns all the SQLs executed in last 7 days and with the cost greater than 10000.
No comments:
Post a Comment