日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

前台等待事件 oracle,Oracle等待事件之buffer busy waits

發(fā)布時(shí)間:2025/3/12 编程问答 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 前台等待事件 oracle,Oracle等待事件之buffer busy waits 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

產(chǎn)生原因

官方定義:

This wait happens when a session wants to access a database block in the buffer cache but it cannot as the buffer is "busy". The two main cases where this can occur are:

Another session is reading the block into the buffer

Another session holds the buffer in an incompatible mode to our request

模擬等待

創(chuàng)建測(cè)試表并插入數(shù)據(jù):

SQL> create table tb1 (id int ,name varchar2(10));

Table created.

SQL> insert into tb1 values (1,'scott');

1 row created.

SQL> insert into tb1 values (2,'tom');

1 row created.

SQL> commit;

Commit complete.

復(fù)制代碼

會(huì)話1修改數(shù)據(jù):

SQL> select userenv('sid') from dual;

USERENV('SID')

--------------

1

SQL> begin

for i in 1..100000 loop

update tb1 set name='rose' where id=2;

commit;

end loop;

end;

/

復(fù)制代碼

會(huì)話2修改數(shù)據(jù):

SQL> select userenv('sid') from dual;

USERENV('SID')

--------------

27

SQL> begin

for i in 1..100000 loop

update tb1 set name='john' where id=1;

commit;

end loop;

end;

/

復(fù)制代碼

在會(huì)話3查看等待情況:

--定位到造成等待的SQL

SQL> SELECT g.inst_id,g.sid,g.serial#,g.event,g.username,g.sql_hash_value,s.sql_fulltext

FROM gv$session g,v$sql s

WHERE g.sql_hash_value = s.hash_value and username='HR' and event='buffer busy waits';

INST_ID SID SERIAL# EVENT USERNAME SQL_HASH_VALUE SQL_FULLTEXT

---------- ---------- ---------- ------------------------------ ---------- -------------- --------------------------------------------------

1 1 7 buffer busy waits HR 401484711 UPDATE TB1 SET NAME='rose' WHERE ID=2

1 27 49 buffer busy waits HR 2040921087 UPDATE TB1 SET NAME='john' WHERE ID=1

--定位到熱點(diǎn)快

SQL> select event,sid,p1,p2,p3 from v$session_wait_history where event='buffer busy waits'

EVENT SID P1 P2 P3

-------------------- ---------- ---------- ---------- ----------

buffer busy waits 1 4 5471 1

buffer busy waits 1 4 5471 1

buffer busy waits 1 4 5471 1

buffer busy waits 1 4 5471 1

buffer busy waits 1 4 5471 1

buffer busy waits 27 4 5471 1

buffer busy waits 27 4 5471 1

buffer busy waits 27 4 5471 1

buffer busy waits 27 4 5471 1

buffer busy waits 27 4 5471 1

10 rows selected.

--P1=file#

--P2=block#

--定位到塊所屬的段

SQL> SELECT OWNER, SEGMENT_NAME, SEGMENT_TYPE, TABLESPACE_NAME, A.PARTITION_NAME FROM DBA_EXTENTS A WHERE FILE_ID = 4 AND 5471 BETWEEN BLOCK_ID AND BLOCK_ID + BLOCKS - 1;

OWNER SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME PARTITION_NAME

---------- -------------------- ------------------ ------------------------------ ------------------------------

HR TB1 TABLE USERS

復(fù)制代碼

解決方法

As buffer busy waits are due to contention for particular blocks then you cannot take any action until you know which blocks are being competed for and why. Eliminating the cause of the contention is the best option. Note that "buffer busy waits" for data blocks are often due to several processes repeatedly reading the same blocks (eg: if lots of people scan the same index) - the first session processes the blocks that are in the buffer cache quickly but then a block has to be read from disk - the other sessions (scanning the same index) quickly 'catch up' and want the block which is currently being read from disk - they wait for the buffer as someone is already reading the block in.

The following hints may be useful for particular types of contention - these are things that MAY reduce contention for particular situations:

Block TypePossible Actionsdata blocksEliminate HOT blocks from the application. Check for repeatedly scanned / unselective indexes. Change PCTFREE and/or PCTUSED. Check for 'right- hand-indexes' (indexes that get inserted into at the same point by many processes). Increase INITRANS. Reduce the number of rows per block.

segment headerIncrease of number of FREELISTs. Use FREELIST GROUPs (even in single instance this can make a difference).

freelist blocksAdd more FREELISTS. In case of Parallel Server make sure that each instance has its own FREELIST GROUP(s).

undo headerAdd more rollback segments.

參考: WAITEVENT: "buffer busy waits" Reference Note (Doc ID 34405.1)

歡迎關(guān)注我的公眾號(hào),一起學(xué)習(xí)。

總結(jié)

以上是生活随笔為你收集整理的前台等待事件 oracle,Oracle等待事件之buffer busy waits的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。