ORACLE TOP SQL
--top 10
SELECT *
FROM (SELECT b.username username,
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 b.username = 'ZYK'
ORDER BY rds_exec_ratio DESC)
WHERE ROWNUM < 11
ORDER BY rds_exec_ratio DESC
1. 識別"低效執行"的SQL語句
用下列SQL工具找出低效SQL:
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
ORDER BY 4 DESC;
2.查詢單條語句的記憶體佔用率
alter system set pga_aggregate_target=10m
alter system set workarea_size_policy=auto;
select distinct * from a where rownum<500000;
select sql_text,operation_type,policy,(last_memory_used/1024/1024),
last_execution,last_tempseg_size
from v$sql i,v$sql_workarea a
where i.hash_value=a.hash_value
and sql_text='select distinct * from a where rownum<500000';
Top 10 by Buffer Gets:
set linesize 100
set pagesize 100
SELECT * FROM
(SELECT substr(sql_text,1,40) sql,
buffer_gets, executions, buffer_gets/executions "Gets/Exec",
hash_value,address
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 substr(sql_text,1,40) sql,
disk_reads, executions, disk_reads/executions "Reads/Exec",
hash_value,address
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,
executions, rows_processed, rows_processed/executions "Rows/Exec",
hash_value,address
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,
parse_calls, executions, hash_value,address
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
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;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/628922/viewspace-682905/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [Oracle Script] Top sqlOracleSQL
- Oracle檢視TOP SQLOracleSQL
- Oracle TOP SQL&&HITOracleSQL
- Oracle AWR Top SQL sectionOracleSQL
- Oracle檢視歷史TOP SQLOracleSQL
- Top 20 SqlSQL
- trace top sql sessionSQLSession
- 各種TOP SQLSQL
- SQL TOP 例項SQL
- Oracle優化案例-教你線上搞定top cpu的sql(十二)Oracle優化SQL
- postgresql定位top cpu sqlSQL
- AWR TOP SQL實現SQL
- TOP N 查詢 SQLSQL
- top sql capture script.SQLAPT
- awr的top sql分析SQL
- For oracle databases, if the top showing the oracle database, then oracle process is using the top cOracleDatabase
- oracle中rownum,sql server中top函式,mysql中limit[轉載]OracleServer函式MySqlMIT
- 12C SQL-TOPSQL
- oracle中top用法Oracle
- 【雲趣科技】Oracle優化案例-教你線上搞定top cpu的sql(十三)Oracle優化SQL
- V$SQLAREA 檢視TOP_SQLSQL
- 產生top sql的原因(zt)SQL
- top sql 產生的歸納SQL
- Oracle Performance Top Issue listOracleORM
- DB2 V9新特性:可以檢視top sql了,類似oracleDB2SQLOracle
- 【SQL】Oracle SQL monitorSQLOracle
- SQL in ORACLE and SQL ServerSQLOracleServer
- AWR 中 top sql 的資訊獲取 - 分析SQL
- 透過top命令抓取cpu高消耗的sqlSQL
- 通過top命令抓取cpu高消耗的sqlSQL
- SQL SERVER 2008的top增強SQLServer
- SQL 語句select top 變數問題SQL變數
- [20130803]ORACLE 12C TOP N SQL實現分頁功能.txtOracleSQL
- Oracle樹 sqlOracleSQL
- Oracle 常用SQLOracleSQL
- oracle SQL with 子句OracleSQL
- Oracle SQL JOINOracleSQL
- first oracle sqlOracleSQL