About Me

I am a Database Administrator with over 13 years of IT experience and my core expertise being Oracle, Oracle Ebusiness Suite and SQL server. Currently I am working as a Database Administrator for Experis US Inc and located in Phoenix, Arizona. I would like to write blogs on whatever I learn on daily basis which might be helpful for others.

Wednesday, November 24, 2010

Find costly SQLs in Oracle 10g

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