【原】Cache Buffer Chain 第四篇

简介: 作者:david_zhang@sh 【转载时请以超链接形式标明文章】 链接:http://www.cnblogs.com/david-zhang-index/p/3873357.html 【测试1】低效的SQL引起的catch buffers chains 锁存器争用 创建测试表 1 c...

作者:david_zhang@sh 【转载时请以超链接形式标明文章】

链接:http://www.cnblogs.com/david-zhang-index/p/3873357.html

【测试1】低效的SQL引起的catch buffers chains 锁存器争用

创建测试表

1 create table cbc_test(id number,name char(100));
2 insert into cbc_test(id,name) select rownum,object_name from dba_objects;

创建索引

1 create index cbc_test_idx on cbc_test(id);

创建扫描表的procedure

1 create or replace procedure cbc_do_select
2 is 3 begin 4 for x in (select /*+ INDEX(cbc_test cbc_test_idx)*/ * from cbc_test where id >= 0) loop 5 null; 6 end loop; 7 end; 8 /

同时打开2000个会话执行读取工作

1 var job_no number;
2 begin
3 for idx in 1..2000 loop
4 dbms_job.submit(:job_no,'cbc_do_select;');
5 commit;
6 end loop;
7 end;
8 /

查看整个系统当前等待

1 SELECT event,
2   total_waits ,
3   time_waited
4 FROM v$session_event
5 WHERE sid=
6   (SELECT sid FROM v$mystat WHERE rownum=1
7   )
8 ORDER BY 3 DESC;

 结果如下:

 1 EVENT                          TOTAL_WAITS TIME_WAITED
 2 ------------------------------ ----------- -----------
 3 SQL*Net message from client             44       46352
 4 library cache lock                     202         253
 5 buffer busy waits                       56         113
 6 latch: In memory undo latch             43          86
 7 latch: cache buffers chains             33          55
 8 control file sequential read         14154          22
 9 db file sequential read                 82          18
10 events in waitclass Other                6          11
11 library cache: mutex X                   8          10
12 latch: shared pool                       4           5
13 latch: row cache objects                 1           2
14 SQL*Net message to client               45           0
15 Disk file operations I/O                 4           0
16 SQL*Net break/reset to client            1           0
17 log file sync                            1           0

根据cache buffers chains事件,找出对应的latch地址

1 select addr, gets, misses, sleeps
2   from v$latch_children
3  where name = 'cache buffers chains'
4    and misses > 100000
5  order by 3 desc;

结果:

1 ADDR                   GETS     MISSES     SLEEPS
2 ---------------- ---------- ---------- ----------
3 0000000124ECCBB0   10485987    5260833          0
4 0000000124E2B5A8   20671341    9806756      27942

根据ADDR找出关联的文件号和块号

 1 SQL> select FILE#,DBABLK,CLASS,STATE from x$bh where HLADDR='0000000124E2B5A8';
 2 
 3      FILE#     DBABLK      CLASS      STATE
 4 ---------- ---------- ---------- ----------
 5          4    3585766          1          1
 6          3       9411         20          1
 7          4    3651302          1          1
 8          4    3581428          1          1
 9          6      71918          1          1
10          6      71918          1          3
11          6      71918          1          3
12          6      71918          1          3
13          6      71918          1          3
14          6      71918          1          3
15          3       5073         38          0

根据文件号和块号,找出对象名称,输入6和71918

1 select owner, segment_name
2   from dba_extents
3  where file_id = &p1
4    and &p2 between block_id and block_id + blocks - 1;

找出的对象名称

1 OWNER                          SEGMENT_NAME
2 ------------------------------ ------------------------------
3 SCOTT                           EMP_FP_IDX1

待续。。。

 

相关文章
|
6月前
|
存储 缓存 算法
内存系列学习(四):Cache和Write Buffer一般性介绍
内存系列学习(四):Cache和Write Buffer一般性介绍
254 0
Cache 和 Buffer 有什么区别?
Cache 和 Buffer 有什么区别?
116 0
|
SQL Oracle 关系型数据库
0821Cache Buffers chains与共享模式疑问4
[20170821]Cache Buffers chains与共享模式疑问4.txt --//昨天别人问的问题,就是在读读模式下,访问相同数据块,11.2.0.4不再出现cache buffers chains latch等待事件.
1177 0
|
缓存
free命令、buffer与cache的区别
freefree 命令相对于top 提供了更简洁的查看系统内存使用情况: # free total used free shared buffers cached Mem: 255988 ...
884 0