模拟产生CBCLATCH与bufferbusywait等待事件
数据库版本:11.2.0.4.0
dbms_rowid.rowid_row_number(rowid) rowid_rownum,
dbms_rowid.rowid_relative_fno(rowid) file_id,
dbms_rowid.rowid_block_number(rowid) block_id,test.* from test;
ROWID ROWID_ROWNUM FILE_ID BLOCK_ID OBJECT_NAME STATUS
------------------ ------------ ---------- ---------- ------------ -------
AAAFSJAAEAAAACkAAA 0 4 164 10 15
AAAFSJAAEAAAACkAAB 1 4 164 10 15
可以看到,TEST表的两条记录在同一文件的同一个BLOCK中。
declare
aa varchar2(100);
begin
for i in 1..1000000 loop
select object_name into aa from test where rowid='AAAFSJAAEAAAACkAAA';
end loop;
end;
/
循环更新查询语句200次 --查询164数据块的第二行
declare
begin
for i in 1..200 loop
update test set status=15 where rowid='AAAFSJAAEAAAACkAAB';
end loop;
commit;
end;
/
BYS@ bys3>select sid from v$mystat where rownum=1;
SID
----------
30
节约篇幅,执行循环的语句就不贴了。
在35号会话执行循环更新语句:
BYS@ bys3>select sid from v$mystat where rownum=1;
SID
----------
35
节约篇幅,执行循环的语句就不贴了。
23:03:21 2 where sid in(30,35);
SID EVENT TOTAL_WAITS TOTAL_TIMEOUTS TIME_WAITED_MICRO
---------- ---------------------------------------- ----------- -------------- -----------------
30 buffer busy waits 1 0 968 --------这里30号会话是读操作,35号会话是写操作,也就是30号会话的读被写阻塞。
30 latch: In memory undo latch 1 0 960
30 resmgr:cpu quantum 3 0 33589
30 SQL*Net message to client 15 0 637
30 SQL*Net message from client 14 0 206010788
35 Disk file operations I/O 3 0 312
35 latch: cache buffers chains 2 0 1174
35 db file sequential read 64 0 9065
35 direct path read 100 0 53191
35 SQL*Net message to client 25 0 259
35 SQL*Net message from client 24 0 625117659
35 SQL*Net break/reset to client 4 0 1046
12 rows selected.
Elapsed: 00:00:00.02
23:03:22 SYS@ bys3>select sid ,event,total_waits,total_timeouts,time_waited_micro from v$session_event
23:03:30 2 where sid in(30,35) and event like '%buffer%';
SID EVENT TOTAL_WAITS TOTAL_TIMEOUTS TIME_WAITED_MICRO
---------- ---------------------------------------- ----------- -------------- -----------------
30 buffer busy waits 1 0 968
35 latch: cache buffers chains 2 0 1174
Elapsed: 00:00:00.03
查看等待事件截图:
1.查出表TEST相关信息
select rowid,dbms_rowid.rowid_row_number(rowid) rowid_rownum,
dbms_rowid.rowid_relative_fno(rowid) file_id,
dbms_rowid.rowid_block_number(rowid) block_id,test.* from test;
ROWID ROWID_ROWNUM FILE_ID BLOCK_ID OBJECT_NAME STATUS
------------------ ------------ ---------- ---------- ------------ -------
AAAFSJAAEAAAACkAAA 0 4 164 10 15
AAAFSJAAEAAAACkAAB 1 4 164 10 15
可以看到,TEST表的两条记录在同一文件的同一个BLOCK中。
2.写一个循环:
循环执行查询语句一百万次:--查询164数据块的第一行declare
aa varchar2(100);
begin
for i in 1..1000000 loop
select object_name into aa from test where rowid='AAAFSJAAEAAAACkAAA';
end loop;
end;
/
循环更新查询语句200次 --查询164数据块的第二行
declare
begin
for i in 1..200 loop
update test set status=15 where rowid='AAAFSJAAEAAAACkAAB';
end loop;
commit;
end;
/
3.打开两个会话,查出会话SID。--这里会话SID分别是30 35.
在30号会话执行循环查询:BYS@ bys3>select sid from v$mystat where rownum=1;
SID
----------
30
节约篇幅,执行循环的语句就不贴了。
在35号会话执行循环更新语句:
BYS@ bys3>select sid from v$mystat where rownum=1;
SID
----------
35
节约篇幅,执行循环的语句就不贴了。
4.再打开一个会话,使用语句查询35 30号会话的等待事件
23:03:20 SYS@ bys3>select sid ,event,total_waits,total_timeouts,time_waited_micro from v$session_event23:03:21 2 where sid in(30,35);
SID EVENT TOTAL_WAITS TOTAL_TIMEOUTS TIME_WAITED_MICRO
---------- ---------------------------------------- ----------- -------------- -----------------
30 buffer busy waits 1 0 968 --------这里30号会话是读操作,35号会话是写操作,也就是30号会话的读被写阻塞。
30 latch: In memory undo latch 1 0 960
30 resmgr:cpu quantum 3 0 33589
30 SQL*Net message to client 15 0 637
30 SQL*Net message from client 14 0 206010788
35 Disk file operations I/O 3 0 312
35 latch: cache buffers chains 2 0 1174
35 db file sequential read 64 0 9065
35 direct path read 100 0 53191
35 SQL*Net message to client 25 0 259
35 SQL*Net message from client 24 0 625117659
35 SQL*Net break/reset to client 4 0 1046
12 rows selected.
Elapsed: 00:00:00.02
23:03:22 SYS@ bys3>select sid ,event,total_waits,total_timeouts,time_waited_micro from v$session_event
23:03:30 2 where sid in(30,35) and event like '%buffer%';
SID EVENT TOTAL_WAITS TOTAL_TIMEOUTS TIME_WAITED_MICRO
---------- ---------------------------------------- ----------- -------------- -----------------
30 buffer busy waits 1 0 968
35 latch: cache buffers chains 2 0 1174
Elapsed: 00:00:00.03
查看等待事件截图:
>更多相关文章
- 11-06Hadoop是目前大数据领域最主流的一套技术体系
- 11-06大数据和人工智能:三个真实世界的用例
- 11-06为什么说,大数据与行业专家是“共生”关系?
- 11-06Python数据可视化:箱线图多种库画法
- 11-06这种思路讲解HDFS你肯定没见过?快速入门Hadoop必备
- 11-06媲美Pandas的数据分析工具包Datatable
首页推荐
佛山市东联科技有限公司一直秉承“一切以用户价值为依归
- 01-11全球最受赞誉公司揭晓:苹果连续九年第一
- 12-09罗伯特·莫里斯:让黑客真正变黑
- 12-09谁闯入了中国网络?揭秘美国绝密黑客小组TA
- 12-09警示:iOS6 惊现“闪退”BUG
- 11-18LG新能源宣布与Bear Robotics达成合作,成为
- 11-18机构:三季度全球个人智能音频设备市场强势
- 11-18闲鱼:注册用户过6亿 AI技术已应用于闲置交
- 11-18美柚、宝宝树回应“涉黄短信骚扰”:未发现
- 11-01京东七鲜与前置仓完成融合
相关文章
24小时热门资讯
24小时回复排行
热门推荐
最新资讯
操作系统
黑客防御