How to identify the SQL consuming more resources in Oracle?


You want to identify the SQL statements consuming more resources in Oracle.


“V$SQLSTATS" view displays performance statistics for SQL statements that have recently executed. You can also use "V$SQL” and “V$SQLAREA" to report on SQL resource usage. 

"V$SQLSTATS” is faster and retains information for a longer period of time, but contains only a subset of the columns in “V$SQL" and "V$SQLAREA”.


select * from( select   sql_text  ,buffer_gets  ,disk_reads  ,sorts  ,cpu_time/1000000 cpu_sec  ,executions  ,rows_processed from v$sqlstats order by cpu_time DESC) where rownum < 20;