1,找出锁定问题
SELECT /*+ ordered */
B.USERNAME, B.SERIAL#, D.ID1, A.SQL_TEXT
FROM V$LOCK D
JOIN V$SESSION B ON B.LOCKWAIT = D.KADDR
JOIN V$SQLTEXT A ON A.ADDRESS = B.SQL_ADDRESS
AND A.HASH_VALUE = B.SQL_HASH_VALUE;
2,检查用户的当前操作及其使用的资源
SELECT A.SID, A.USERNAME, S.SQL_TEXT
FROM V$SESSION A, V$SQLTEXT S
WHERE A.SQL_ADDRESS = S.ADDRESS
AND A.SQL_HASH_VALUE = S.HASH_VALUE
ORDER BY A.USERNAME, A.SID, S.PIECE;
3,查看v$sql_bind_capture,看看average binds是否大于15
SELECT sql_id,COUNT(*) bind_count FROM v$sql_bind_capture
WHERE child_number=0 GROUP BY sql_id HAVING COUNT(*) >20 ORDER BY COUNT(*) DESC;
4,查看有问题的SQL并修复:
SELECT sql_text,users_executing,executions,users_opening,buffer_gets
FROM v$sqlarea WHERE sql_id='cprfzqn5y3w1h' ORDER BY buffer_gets;
SELECT SIZE_FOR_ESTIMATE,
BUFFERS_FOR_ESTIMATE,
ESTD_PHYSICAL_READ_FACTOR,
ESTD_PHYSICAL_READS
FROM V$DB_CACHE_ADVICE
WHERE NAME = 'DEFAULT'
AND BLOCK_SIZE =
(SELECT VALUE FROM V$PARAMETER WHERE NAME = 'db_block_size')
AND ADVICE_STATUS = 'ON';
SELECT sum(gets),SUM(getmisses),(1-SUM(getmisses)/(SUM(gets)+SUM(getmisses))) * 100 HitRate FROM v$rowcache;