常用的Oracle查询TOP语句。
Top 10 by Buffer Gets: 最耗缓存
set linesize 100 set pagesize 100 SELECT * FROM (SELECT SQL_FULLTEXT sql, buffer_gets, executions, buffer_gets/executions "Gets/Exec", hash_value,address,LAST_ACTIVE_TIME FROM V$SQLAREA WHERE buffer_gets > 10000 ORDER BY buffer_gets DESC) WHERE rownum <= 10 ;
Top 10 by Physical Reads: 最多物理读取
set linesize 100 set pagesize 100 SELECT * FROM (SELECT SQL_FULLTEXT sql, disk_reads, executions, disk_reads/executions "Reads/Exec", hash_value,address,LAST_ACTIVE_TIME FROM V$SQLAREA WHERE disk_reads > 1000 ORDER BY disk_reads DESC) WHERE rownum <= 10 ;
Top 10 by Executions: 最多执行
set linesize 100 set pagesize 100 SELECT * FROM (SELECT substr(sql_text,1,40) sql,SQL_FULLTEXT, executions, rows_processed, rows_processed/executions "Rows/Exec", hash_value,address,LAST_ACTIVE_TIME FROM V$SQLAREA WHERE executions > 100 ORDER BY executions DESC) WHERE rownum <= 10 ;
Top 10 by Parse Calls: 最多软解析
set linesize 100 set pagesize 100 SELECT * FROM (SELECT substr(sql_text,1,40) sql, SQL_FULLTEXT, parse_calls, executions, hash_value,address,LAST_ACTIVE_TIME FROM V$SQLAREA WHERE parse_calls > 1000 ORDER BY parse_calls DESC) WHERE rownum <= 10 ;
Top 10 by Sharable Memory: 最耗内存
set linesize 100 set pagesize 100 SELECT * FROM (SELECT substr(sql_text,1,40) sql, sharable_mem, executions, hash_value,address,LAST_ACTIVE_TIME FROM V$SQLAREA WHERE sharable_mem > 1048576 ORDER BY sharable_mem DESC) WHERE rownum <= 10 ;
Top 10 by Version Count:
set linesize 100 set pagesize 100 SELECT * FROM (SELECT substr(sql_text,1,40) sql, version_count, executions, hash_value,address FROM V$SQLAREA WHERE version_count > 20 ORDER BY version_count DESC) WHERE rownum <= 10 ;