查詢數據庫耗費資源的sql


SELECT S.module, S.SQL_TEXT,
S.SQL_FULLTEXT,
S.SQL_ID,
ROUND(ELAPSED_TIME / 1000000 / (CASE
WHEN (EXECUTIONS = 0 OR NVL(EXECUTIONS, 1 ) = 1) THEN
1
ELSE
EXECUTIONS
END),
2) "執行時間'S'",
S.EXECUTIONS "執行次數",
S.OPTIMIZER_COST "COST",
S.SORTS,
S.MODULE, --鏈接模式(JDBC THIN CLIENT:程序)
-- S.LOCKED_TOTAL,
S.PHYSICAL_READ_BYTES "物理讀",
-- S.PHYSICAL_READ_REQUESTS "物理讀請求",
S.PHYSICAL_WRITE_REQUESTS "物理寫",
-- S.PHYSICAL_WRITE_BYTES "物理寫請求",
S.ROWS_PROCESSED "返回行數",
S.DISK_READS "磁盤讀",
S.DIRECT_WRITES "直接路徑寫",
S.PARSING_SCHEMA_NAME,
S.LAST_ACTIVE_TIME
FROM GV$SQLAREA S
WHERE ROUND(ELAPSED_TIME / 1000000 / (CASE
WHEN (EXECUTIONS = 0 OR NVL(EXECUTIONS, 1 ) = 1) THEN
1
ELSE
EXECUTIONS
END),
2) > 30 --100 0000微秒=1S [>5s]
AND S.PARSING_SCHEMA_NAME = USER
AND TO_CHAR(S.LAST_LOAD_TIME, 'YYYY-MM-DD') =
TO_CHAR( SYSDATE, 'YYYY-MM-DD' )
AND S.COMMAND_TYPE IN (2 , 3, 5, 6 , 189)
ORDER BY "執行時間'S'" DESC;module

相關文章
相關標籤/搜索