無工具情況下Oracle應急診斷思路(一)
一、發現哪些session導致瓶頸或等在什麼event上
在Oracle10g上,透過v$session檢視就能找到瓶頸session,而Oracle9i中,除了v$session 還需要查詢v$session_wait檢視,具體如下:
在oracle 9i
select event, count(*) sessions from v$session_wait
where state='WAITING'
and Event not like '%SQL*Net%'
and USERNAME is not null
group by event
order by 2 desc;
select SW.Sid, S.Username, SW.Event, SW.Wait_Time,
SW.State, SW.Seconds_In_Wait SEC_IN_WAIT
from V$SESSION S, V$SESSION_WAIT SW
where S.Username is not null
and SW.Sid = S.Sid
and SW.Event not like '%SQL*Net%'
order by SW.Wait_Time Desc;
[@more@]在oracle 10g
select event, count(*) sessions from v$session
where state='WAITING'
and event not like '%SQL*Net%'
and USERNAME is not null
group by event
order by 2 desc;
select s.SID,s.USERNAME,s.EVENT,s.WAIT_TIME,s.SECONDS_IN_WAIT,s.LAST_CALL_ET,s.STATE,
s.BLOCKING_SESSION,s.BLOCKING_SESSION_STATUS
from v$session
where s.USERNAME is not null
and s.STATUS = 'ACTIVE'
and s.EVENT not like '%SQL*Net%'
order by s.SECONDS_IN_WAIT;
知道有問題session後,需要進一步查出導致等待的物件或SQL,在此針對不同evet需要採取不同的處理方法,對db file scattered read和db file sequential read類event,可以採取如下查詢:
--確定導致等待物件:
select Sid, Event, P1text, P1, P2text, P2, P3text, P3,SQL_ADDRESS,SQL_HASH_VALUE
from V$SESSION
where event not like '%SQL%'
and Event not like '%rdbms%';
and Sid between &sid1 and &sid2
select Owner, Segment_Name, Segment_Type, Tablespace_Name
from DBA_EXTENTS
where File_Id = &FileId_In
and &BlockId_In between Block_Id and Block_Id + Blocks - 1;
--確定導致等待的SQL:
select sql_id,child_number,sql_text,sql_fulltext from v$sql
where hash_value=&hv
and address=&addr
--找出該SQL相關的執行計劃:
呼叫dbms_xplan包,檢視該語句執行時的執行計劃:
select * from table(dbms_xplan.display_cursor('sql_id'));
SQL> select * from table(dbms_xplan.display_cursor('9dy3zmd40w004'));
根據SQL執行計劃,最佳化SQL,即對該SQL相關索引進行最佳化
如下為全表掃描和索引掃描的英文解釋,共參考:
db file scattered readThe db file scattered read event is posted by the session when it issues an I/O request to read multiple data blocks. The blocks read from the datafiles are scattered into the buffer cache. These blocks need not remain contiguous in the buffer cache. The event typically occurs during full table scans or index fast full scans. The initialization parameter, DB_FILE_MULTIBLOCK_READ_COUNT determines the maximum number of data blocks to read.
Waiting on datafile I/O completion is normal in any Oracle database. The presence of this wait event does not necessarily indicate a performance problem. However, if the time spent waiting for multiblock reads is significant compared to other waits, you must investigate the reason for it.
Wait Parameters
Wait parameters for db file scattered read are described here:
• P1 File number to read the blocks from
• P2 Starting block number to begin reading
• P3 Number of blocks to read
Wait Time
No timeouts. The session waits until all of the I/Os are completed to read specified number of blocks.
db file sequential readThe db file sequential read wait event occurs when the process waits for an I/O completion for a sequential read. The name is a bit misleading, suggesting a multiblock operation, but this is a single block read operation. The event gets posted when reading from an index, rollback or undo segments, table access by rowid, rebuilding control files, dumping datafile headers, or the datafile headers.
Waiting on datafile I/O completion is normal in any Oracle Database. The presence of this wait event does not necessarily indicate a performance problem. However, if the time spent waiting for single block reads is significant compared to other waits, you must investigate the reason for it.
Wait Parameters
No timeouts. Wait parameters for db file sequential read are described here:
• P1 File number to read the data block from
• P2 Starting block number to read
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/18841027/viewspace-1058765/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 無工具情況下Oracle應急診斷思路(二)Oracle
- 綠盟科技分享工業資訊保安應急響應能力建設思路
- Oracle效能診斷一例Oracle
- Oracle診斷事件例項(一)Oracle事件
- 轉一個白老大的文章--- 一個診斷的思路
- ORACLE診斷案例Oracle
- Oracle故障診斷Oracle
- ORACLE診斷事件Oracle事件
- oracle 效能診斷工具Oracle
- Oracle診斷事件列表Oracle事件
- ORACLE診斷事件(zt)Oracle事件
- 一次ORACLE IO效能診斷案例Oracle
- 一次Oracle診斷案例-Spfile案例Oracle
- Oracle效能問題診斷一例Oracle
- [JVM] 應用診斷工具之Fastthread(線上診斷)JVMASTthread
- 一次Oracle診斷案例-SGA與SwapOracle
- Oracle診斷事件列表(轉)Oracle事件
- oracle診斷工具-RDA使用Oracle
- oracle 事件診斷詳細Oracle事件
- oracle sqlt(sqltxplain) 診斷工具OracleSQLAI
- Oracle診斷工具RDA使用Oracle
- Oracle效能診斷藝術Oracle
- 無線網路異常的一次診斷
- oracle 10046事件故障診斷一例Oracle事件
- oracle 效能診斷藝術優化一書到手Oracle優化
- 9 Oracle Data Guard 故障診斷Oracle
- Oracle診斷案例-Sql_traceOracleSQL
- oracle之 redo過高診斷Oracle
- Oracle所有診斷事件列表eventsOracle事件
- Oracle中診斷阻塞的sessionOracleSession
- 【Oracle】資料庫hang 診斷Oracle資料庫
- Oracle GoldenGate(OGG)診斷OracleGo
- 【轉】oracle診斷工具-RDA使用Oracle
- Oracle配置資料庫診斷Oracle資料庫
- oracle 10053診斷事件Oracle事件
- ORACLE診斷事件的總結Oracle事件
- oracle診斷工具-RDA使用(轉)Oracle
- 線上故障突突突?如何緊急診斷、排查與恢復