您的位置:首页 > 大数据 > 人工智能

waits events statisc

2016-07-01 16:49 330 查看
--buffer busy waits
select sw.P1 "FILD ID", sw.P2 "Block ID", sw.P3 "Class ID"
from V$session_Wait sw where sw.EVENT='buffer busy waits'

SELECT s.ROW_WAIT_OBJ# FROM V$SESSION s where event = 'buffer busy waits'

select do.OWNER, do.OBJECT_NAME, do.SUBOBJECT_NAME, do.OBJECT_TYPE
from dba_objects do
where do.DATA_OBJECT_ID = &ROW_WAIT_OBJ#
/*db file scattered read multiblock read => a fast full scan(of an index)
a full table scan*/

select sw.P1 "obsolute file number", sw.P2 "block begin read",
sw.P3 "the number of blocks"
from V$session_Wait sw
where sw.EVENT = 'db file scattered read'

--
select s.SQL_ADDRESS, s.SQL_HASH_VALUE
from v$session s
where s.EVENT = 'db file%read'

SELECT s.ROW_WAIT_OBJ#
FROM V$SESSION s
where event = 'db file scattered read'

select do.OWNER, do.OBJECT_NAME, do.SUBOBJECT_NAME, do.OBJECT_TYPE
from dba_objects do
where do.DATA_OBJECT_ID = &ROW_WAIT_OBJ#

--db file sequential read a single-block

select sw.P1 "obsolute file number", sw.P2 "block begin read",
sw.P3 "the number of blocks"
from V$session_Wait sw
where sw.EVENT = 'db file scattered read'

/* db file sequential read (single block read into one SGA buffer)
* db file scattered read (multiblock read into many discontinuous SGA buffers)
* db direct read (single or multiblock read into the PGA, bypassing the SGA)*/

-- db file direct path and direct read temp
select sw.P1 "file_id", sw.P2 "start_block_id",
sw.P3 "the number of blocks"
from V$session_Wait sw
where sw.EVENT = 'db file direct path write'

--causees
/* The sorts are too large
* parallel slaves are used for scanning data */

--db file direct write
select sw.P1 "file_id", sw.P2 "start_block_id",
sw.P3 "the number of blocks"
from V$session_Wait sw
where sw.EVENT = 'db file direct path write'
/* sorts are too large to fit in memory and are written to disk
* parallel DML are issued to create/populate objects
* direct path loads*/

/*enqueue(enq):waits This event iddiates that the session is waiting for a lock
* that is held by another session,such as following related TX types:
* enq: TX-allocate ITL entry
* enq: TX-contention
* enq: TX-index contention
* enq: TX-row lock contention*/

select sw.P1 "LOCK TYPE", P2 "Resource identifier ID1",
p3 "Resource identifier ID3"
from v$session_wait sw
where sw.EVENT like 'enq: TX - row lock contention'
select * from v$lock l where l.REQUEST>0

SELECT DECODE(REQUEST, 0, 'Holder: ', 'Waiter:') || sid sess, id1, id2,lmode,
request, type
from v$lock
where (id1, id2, type) in
(select id1, id2, type from v$lock where request > 0)
order by id1, request

--blocking session
select s1.username || '@' || s1.machine || ' ( SID=' || s1.sid ||
' ) is blocking ' || s2.username || '@' || s2.machine || ' ( SID=' ||
s2.sid || ' ) ' AS blocking_status
from v$lock l1, v$session s1, v$lock l2, v$session s2
where s1.sid = l1.sid
and s2.sid = l2.sid
and l1.BLOCK = 1
and l2.request > 0
and l1.id1 = l2.id1
and l2.id2 = l2.id2
select a.SERIAL# from v$session a where a.SID=211
alter system kill session '211,485';
--free buffer waits
/*This wait event indicates that a server process was unable to find a free buffer and has
posted the database writer to make free buffers by writing out dirty buffers. A dirty
buffer is a buffer whose contents have been modified. Dirty buffers are freed for reuse
when DBWR has written the blocks to disk.
Causes
DBWR may not be keeping up with writing dirty buffers in the following situations:
■ The I/O system is slow.
■ There are resources it is waiting for, such as latches.
■ The buffer cache is so small that DBWR spends most of its time cleaning out
buffers for server processes.
■ The buffer cache is so big that one DBWR process is not enough to free enough
buffers in the cache to satisfy requests.*/

select * from v$filestat;
select * from V$DB_CACHE_ADVICE;

--latch events

/*A latch is a low-level internal lock used by Oracle Database to protect memory
structures. The latch free event is updated when a server process attempts to get a
latch, and the latch is unavailable on the first attempt.
There is a dedicated latch-related wait event for the more popular latches that often
generate significant contention. For those events, the name of the latch appears in the
name of the wait event, such as latch: library cache or latch: cache buffers
chains . This enables you to quickly figure out if a particular type of latch is
responsible for most of the latch-related contention. Waits for all other latches are
grouped in the generic latch free wait event.*/
/*
Check the following V$SESSION_WAIT parameter columns:
■ P1 : Address of the latch
■ P2 : Latch number
■ P3 : Number of times process has slept, waiting for the latch*/

select sw.EVENT, sum(sw.P3) SLERPS, sum(sw.SECONDS_IN_WAIT) seconds_in_wait
from v$session_wait sw
where sw.EVENT like 'latch%'
group by sw.EVENT

select se.EVENT, se.TIME_WAITED_MICRO,
round(se.TIME_WAITED_MICRO * 100 / s.DBTIME, 1) PCT_DB_TIME
from v$system_event se,
(select stm.VALUE DBTIME
from v$sys_time_model stm
where stm.STAT_NAME = 'DB time') s
where se.EVENT like 'latch%'
order by PCT_DB_TIME ASC

SELECT E.EVENT, E.WAIT_CLASS, E.TIME_WAITED_MICRO,
ROUND(TIME_WAITED_MICRO * 100 / S.DBTIME, 1) PCT_DB_TIME
FROM V$SYSTEM_EVENT E, V$EVENT_NAME N,
(SELECT VALUE DBTIME
FROM V$SYS_TIME_MODEL
WHERE STAT_NAME = 'DB time') S
WHERE E.EVENT_ID = N.EVENT_ID
AND N.WAIT_CLASS NOT IN ('Idle', 'System I/O')
ORDER BY PCT_DB_TIME ASC;

--shared pool ibrary cache
SELECT SQL_TEXT FROM V$SQLSTATS WHERE EXECUTIONS < 4 ORDER BY SQL_TEXT;

SELECT SUBSTR(SQL_TEXT, 1, 60), COUNT(*)
FROM V$SQLSTATS
WHERE EXECUTIONS < 4
GROUP BY SUBSTR(SQL_TEXT, 1, 60)
HAVING COUNT(*) > 1;

SELECT SQL_TEXT
FROM V$SQLSTATS
WHERE PLAN_HASH_VALUE IN (SELECT PLAN_HASH_VALUE
FROM V$SQLSTATS
GROUP BY PLAN_HASH_VALUE
HAVING COUNT(*) > 4)
ORDER BY PLAN_HASH_VALUE;

SELECT pa.SID, pa.VALUE "Hard Parses", ex.VALUE "Execute Count"
FROM V$SESSTAT pa, V$SESSTAT ex
WHERE pa.SID = ex.SID
AND pa.STATISTIC# =
(SELECT STATISTIC# FROM V$STATNAME WHERE NAME = 'parse count (hard)')
AND ex.STATISTIC# =
(SELECT STATISTIC# FROM V$STATNAME WHERE NAME = 'execute count')
AND pa.VALUE > 0;

---chax
select c.OBJECT_NAME, a.ROW_WAIT_OBJ#, a.ROW_WAIT_FILE#, a.ROW_WAIT_BLOCK#,
a.ROW_WAIT_ROW#,
dbms_rowid.rowid_create(1,
c.OBJECT_ID,
a.ROW_WAIT_FILE#,
a.ROW_WAIT_BLOCK#,
a.ROW_WAIT_ROW#) rid
from v$session a, v$enqueue_lock b, dba_objects c
where a.sid = b.SID
and b.type = 'TX'
and a.ROW_WAIT_OBJ# = object_id(+)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  oracle