/****View the sql with the most resources*****/
select
PARSING_USER_ID ,VERSION_COUNT,SQL_TEXT,CPU_TIME,ELAPSED_TIME,EXECUTIONS,
ROWS_PROCESSED,
HASH_VALUE,
buffer_gets ,
disk_reads
from V$SQLAREA
WHERE buffer_gets > 10000000 OR disk_reads > 1000000
ORDER BY buffer_gets + 100 * disk_reads DESC;
/***** View the resource consumption of a SQL statement: **********
SELECT hash_value, buffer_gets, disk_reads, executions, parse_calls
FROM V$SQLAREA
WHERE hash_Value = 228801498 AND address = hextoraw('CBD8E4B0');
/********************8 Find the top 10 SQL statements with poor performance **************
SELECT * FROM (select PARSING_USER_ID,EXECUTIONS,SORTS,COMMAND_TYPE,DISK_READS,sql_text
FROM v$sqlarea
order BY disk_reads DESC )where ROWNUM<10 ;
/****************************8 Analysis of sql with poor performance ***************** ****************/
SELECT EXECUTIONS , DISK_READS, BUFFER_GETS,
ROUND((BUFFER_GETS-DISK_READS)/BUFFER_GETS,2)
Hit_radio,
ROUND(DISK_READS/EXECUTIONS,2) Reads_per_run,
SQL_TEXT
FROM V$SQLAREA
WHERE
EXECUTIONS>0
AND BUFFER_GETS >0
AND (BUFFER_GETS-DISK_READS)/BUFFER_GETS < 0.8
Query the parsed SQL statements and related information in the shared pool
--EXECUTIONS The number of times this statement is executed for all child cursors
--DISK_READS The number of disk reads caused by all child cursors running this statement
--BUFFER_GETS The number of memory reads caused by all child cursors running this statement
--Hit_radio hit rate
--Reads_per_run read and write the number of disks per execution
Generally speaking, the higher the EXECUTIONS, BUFFER_GETS, and Hit_radio are, the more memory is read, and the less disk is an ideal state.
the higher the better
/************************Select the most resource-intensive query********/
select b.username username,a.disk_reads reads,a.executions exec,
a.disk_reads/decode(a.executions,0,1,a.executions) rds_exec_ratio,
a.sql_text statement
from v$sqlarea a,dba_users b
where a.parsing_user_id=b.user_id
and a.disk_reads>100000
--------------------View the statements executed by the current session and session related information-----
select a.sid,a.sql_address,s.address,a.username,a.TERMINAL,a.program,
s.sql_text,s.SQL_TEXT,s.CPU_TIME,s.ELAPSED_TIME,s.FIRST_LOAD_TIME,s.LAST_ACTIVE_TIME from
v$session a
,v$sqlarea s
where a.sql_address = s.address(+)
and a.sql_hash_value = s.hash_value(+)
order by a.username, a.sid