shared pool 锁存器起到的保护堆(共享池的基本内存结构)的作用,为了查找Free Chunk,检索空闲列,分配适当的Chunk,必要时分割空闲的Chunk的一连串工作,
全都只能在获得shared pool锁存器后才能发生.在获得shared pool锁存器过程中发生争用,则等待latch:shared pool事件。
与堆相关的一连串工作大部分在非常短的时间内结束,因此一般情况下不出现shared pool锁存器争用。但是如下情况下,可能增加latch:shared pool等待。
shared pool 锁存器一般在整个实例上只存在一个,即,一个共享池上使用一个shared pool锁存器,这是基于共享池基本内存结构-----堆的结构决定的,因此,
多个会话同时想要分配Chunk时,为了获得唯一的shared pool锁存器发生争用。
*Hard Parsing 严重时,经常发生分割Chunk的现象,因此在空闲列上出现许多较小的空闲Chunk的现象,这种现象称为共享池的碎片化。因共享池的碎片化,延长查询空闲列的时间,
相应拥有shared pool锁存器的时间也会延长。共享池碎片化是引发shared pool锁存器争用的根本原因。
过多发生Hard Parsing时,测试shared pool锁存器争用怎样发生,测试方案如下:
---确认SGA大小
SQL> show sga
Total System Global Area 730714112 bytes
Fixed Size 2231952 bytes
Variable Size 402653552 bytes
Database Buffers 318767104 bytes
Redo Buffers 7061504 bytes
开多个窗口执行如下SQL:
begin
for i in 1 .. 100000000
loop
execute immediate 'select '||i||' from test test'||i;
end loop;
end;
执行的sql为select 31808 from test test31808
p1 p2 p3
1 03-7月 -14 11.50.00.566 上午 1619 latch: shared pool 1611562952 214 0 0 -1 0 0
2 03-7月 -14 11.49.57.566 上午 1616 latch: shared pool 1611562952 214 0 0 -1 0 0
3 03-7月 -14 11.49.57.566 上午 1619 latch: shared pool 1611562952 214 0 0 -1 0 0
4 03-7月 -14 11.48.57.486 上午 1619 latch: shared pool 1611562952 214 0 0 -1 0 0
5 03-7月 -14 11.48.57.486 上午 1623 latch: shared pool 1611562952 214 0 0 -1 0 0
6 03-7月 -14 11.48.38.435 上午 1619 latch: shared pool 1611562952 214 0 0 -1 0 0
7 03-7月 -14 11.48.13.395 上午 1619 latch: shared pool 1611562952 214 0 0 -1 0 0
8 03-7月 -14 11.45.45.144 上午 1622 latch: shared pool 1611562952 214 0 0 -1 0 0
9 03-7月 -14 11.45.08.084 上午 1615 latch: shared pool 1611562952 214 0 0 -1 0 0
10 03-7月 -14 11.44.34.024 上午 1615 latch: shared pool 1611562952 214 0 0 -1 0 0
11 03-7月 -14 11.44.27.014 上午 1622 latch: shared pool 1611562952 214 0 0 -1 0 0
12 03-7月 -14 11.43.44.954 上午 1615 latch: shared pool 1611562952 214 0 0 -1 0 0
13 03-7月 -14 11.43.35.944 上午 1622 latch: shared pool 1611562952 214 1 0 -1 0 0
14 03-7月 -14 11.43.22.924 上午 1622 latch: shared pool 1611562952 214 2 0 -1 0 0
15 03-7月 -14 11.42.46.844 上午 1626 latch: shared pool 1611562952 214 0 0 -1 0 0
16 03-7月 -14 11.42.22.738 上午 1615 latch: shared pool 1611562952 214 0 0 -1 0 0
17 03-7月 -14 11.42.22.738 上午 1622 latch: shared pool 1611562952 214 0 0 -1 0 0
18 03-7月 -14 11.42.22.738 上午 1624 latch: shared pool 1611562952 214 0 0 -1 0 0
19 03-7月 -14 11.42.22.738 上午 1626 latch: shared pool 1611562952 214 0 0 -1 0 0
20 03-7月 -14 11.42.22.738 上午 1628 latch: shared pool 1611562952 214 0 0 -1 0 0
21 03-7月 -14 11.42.17.538 上午 1624 latch: shared pool 1611562952 214 0 0 -1 0 0
22 03-7月 -14 11.42.12.458 上午 1628 latch: shared pool 1611562952 214 0 0 -1 0 0
p1 latch 地址
p2 latch 编号