檢視資料庫最佔資源或記憶體的查詢SQL

路途中的人2012發表於2016-12-09

1.使用下面查詢修正資料庫中最佔資源的查詢
select b.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 order by a.DISK_READS desc;

 select * from
        (select sql_text,address,
        rank() over(order by buffer_gets desc) as rank_bufgets,
        to_char(100*ratio_to_report(buffer_gets) over(), '999.99') pct_bufgets
        from v$sql )
  where rank_bufgets < 11;

2.使用下面查詢修正資料庫中最佔記憶體的查詢
select b.username, a.buffer_gets buffergets, a.EXECUTIONS exec, a.buffer_gets /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.buffer_gets > 100000 order by a.buffer_gets desc;

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29067253/viewspace-2130151/,如需轉載,請註明出處,否則將追究法律責任。

相關文章