- 最后登录
- 2023-8-16
- 在线时间
- 1686 小时
- 威望
- 2135
- 金钱
- 50532
- 注册时间
- 2011-10-12
- 阅读权限
- 200
- 帖子
- 5207
- 精华
- 39
- 积分
- 2135
- UID
- 2
|
2#
发表于 2012-3-8 22:50:33
我原本以为不会, 做了一次测试发现是会的
SQL> select * from V$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
SQL> select a.ksppinm "Parameter",
2 b.ksppstvl "Session Value",
3 c.ksppstvl "Instance Value"
4 from sys.x$ksppi a, sys.x$ksppcv b, sys.x$ksppsv c
5 where a.indx = b.indx and a.indx = c.indx
6 and a.ksppinm like '%kghdsidx%';
Parameter
--------------------------------------------------------------------------------
Session Value
--------------------------------------------------------------------------------
Instance Value
--------------------------------------------------------------------------------
_kghdsidx_count
1
1
_kghdsidx_count=1 只有一个 shared pool subpool
begin
for i in 1..10000 loop
execute immediate 'select 1 from dual where 1='||i;
end loop;
end;
/
==> 生成大量非共享cursor- ttitle off
- set heading on
- set feedback on
- select '0 (<140)' BUCKET,
- KSMCHCLS,
- KSMCHIDX,
- 10 * trunc(KSMCHSIZ / 10) "From",
- count(*) "Count",
- max(KSMCHSIZ) "Biggest",
- trunc(avg(KSMCHSIZ)) "AvgSize",
- trunc(sum(KSMCHSIZ)) "Total"
- from x$ksmsp
- where KSMCHSIZ < 140
- and KSMCHCLS = 'free'
- group by KSMCHCLS, KSMCHIDX, 10 * trunc(KSMCHSIZ / 10)
- UNION ALL
- select '1 (140-267)' BUCKET,
- KSMCHCLS,
- KSMCHIDX,
- 20 * trunc(KSMCHSIZ / 20),
- count(*),
- max(KSMCHSIZ),
- trunc(avg(KSMCHSIZ)) "AvgSize",
- trunc(sum(KSMCHSIZ)) "Total"
- from x$ksmsp
- where KSMCHSIZ between 140 and 267
- and KSMCHCLS = 'free'
- group by KSMCHCLS, KSMCHIDX, 20 * trunc(KSMCHSIZ / 20)
- UNION ALL
- select '2 (268-523)' BUCKET,
- KSMCHCLS,
- KSMCHIDX,
- 50 * trunc(KSMCHSIZ / 50),
- count(*),
- max(KSMCHSIZ),
- trunc(avg(KSMCHSIZ)) "AvgSize",
- trunc(sum(KSMCHSIZ)) "Total"
- from x$ksmsp
- where KSMCHSIZ between 268 and 523
- and KSMCHCLS = 'free'
- group by KSMCHCLS, KSMCHIDX, 50 * trunc(KSMCHSIZ / 50)
- UNION ALL
- select '3-5 (524-4107)' BUCKET,
- KSMCHCLS,
- KSMCHIDX,
- 500 * trunc(KSMCHSIZ / 500),
- count(*),
- max(KSMCHSIZ),
- trunc(avg(KSMCHSIZ)) "AvgSize",
- trunc(sum(KSMCHSIZ)) "Total"
- from x$ksmsp
- where KSMCHSIZ between 524 and 4107
- and KSMCHCLS = 'free'
- group by KSMCHCLS, KSMCHIDX, 500 * trunc(KSMCHSIZ / 500)
- UNION ALL
- select '6+ (4108+)' BUCKET,
- KSMCHCLS,
- KSMCHIDX,
- 1000 * trunc(KSMCHSIZ / 1000),
- count(*),
- max(KSMCHSIZ),
- trunc(avg(KSMCHSIZ)) "AvgSize",
- trunc(sum(KSMCHSIZ)) "Total"
- from x$ksmsp
- where KSMCHSIZ >= 4108
- and KSMCHCLS = 'free'
- group by KSMCHCLS, KSMCHIDX, 1000 * trunc(KSMCHSIZ / 1000)
- /
- BUCKET KSMCHCLS KSMCHIDX From Count Biggest AvgSize Total
- -------------- -------- ---------- ---------- ---------- ---------- ---------- ----------
- 0 (<140) free 1 50 85 56 56 4760
- 0 (<140) free 1 110 73 112 112 8176
- 0 (<140) free 1 70 48 72 72 3456
- 0 (<140) free 1 80 86 88 84 7248
- 0 (<140) free 1 120 135 128 125 16904
- 0 (<140) free 1 60 162 64 64 10368
- 0 (<140) free 1 40 206 48 43 8992
- 0 (<140) free 1 90 70 96 96 6720
- 0 (<140) free 1 130 73 136 136 9928
- 0 (<140) free 1 100 60 104 104 6240
- 1 (140-267) free 1 140 113 152 147 16640
- 1 (140-267) free 1 200 34 216 200 6824
- 1 (140-267) free 1 240 9 256 247 2224
- 1 (140-267) free 1 220 181 232 231 41872
- 1 (140-267) free 1 260 31 264 264 8184
- 1 (140-267) free 1 160 77 168 160 12360
- 2 (268-523) free 1 450 1 472 472 472
- 2 (268-523) free 1 300 57 344 330 18824
- 2 (268-523) free 1 350 449 392 364 163720
- 2 (268-523) free 1 400 1 408 408 408
- 2 (268-523) free 1 250 17 296 284 4840
- 3-5 (524-4107) free 1 500 1 544 544 544
- 3-5 (524-4107) free 1 3000 1 3336 3336 3336
- 3-5 (524-4107) free 1 1000 1 1112 1112 1112
- 6+ (4108+) free 1 8000 40 8712 8590 343600
复制代码 可以看到以上 bucket 0 (<140) 中有不少 size小于149 bytes 的小的free chunk
之后我们alter sytem flush shared_pool ;- SQL> alter system flush shared_pool;
- System altered.
- SQL> ttitle off
- SQL> set heading on
- SQL> set feedback on
- SQL>
- SQL> select '0 (<140)' BUCKET,
- 2 KSMCHCLS,
- 3 KSMCHIDX,
- 4 10 * trunc(KSMCHSIZ / 10) "From",
- 5 count(*) "Count",
- 6 max(KSMCHSIZ) "Biggest",
- 7 trunc(avg(KSMCHSIZ)) "AvgSize",
- 8 trunc(sum(KSMCHSIZ)) "Total"
- 9 from x$ksmsp
- 10 where KSMCHSIZ < 140
- 11 and KSMCHCLS = 'free'
- 12 group by KSMCHCLS, KSMCHIDX, 10 * trunc(KSMCHSIZ / 10)
- 13 UNION ALL
- 14 select '1 (140-267)' BUCKET,
- 15 KSMCHCLS,
- 16 KSMCHIDX,
- 17 20 * trunc(KSMCHSIZ / 20),
- 18 count(*),
- 19 max(KSMCHSIZ),
- 20 trunc(avg(KSMCHSIZ)) "AvgSize",
- 21 trunc(sum(KSMCHSIZ)) "Total"
- 22 from x$ksmsp
- 23 where KSMCHSIZ between 140 and 267
- 24 and KSMCHCLS = 'free'
- 25 group by KSMCHCLS, KSMCHIDX, 20 * trunc(KSMCHSIZ / 20)
- 26 UNION ALL
- 27 select '2 (268-523)' BUCKET,
- 28 KSMCHCLS,
- KSMCHIDX,
- 29 30 50 * trunc(KSMCHSIZ / 50),
- 31 count(*),
- 32 max(KSMCHSIZ),
- 33 trunc(avg(KSMCHSIZ)) "AvgSize",
- 34 trunc(sum(KSMCHSIZ)) "Total"
- 35 from x$ksmsp
- 36 where KSMCHSIZ between 268 and 523
- 37 and KSMCHCLS = 'free'
- 38 group by KSMCHCLS, KSMCHIDX, 50 * trunc(KSMCHSIZ / 50)
- 39 UNION ALL
- 40 select '3-5 (524-4107)' BUCKET,
- 41 KSMCHCLS,
- 42 KSMCHIDX,
- 43 500 * trunc(KSMCHSIZ / 500),
- 44 count(*),
- max(KSMCHSIZ),
- 45 46 trunc(avg(KSMCHSIZ)) "AvgSize",
- 47 trunc(sum(KSMCHSIZ)) "Total"
- 48 from x$ksmsp
- 49 where KSMCHSIZ between 524 and 4107
- 50 and KSMCHCLS = 'free'
- 51 group by KSMCHCLS, KSMCHIDX, 500 * trunc(KSMCHSIZ / 500)
- 52 UNION ALL
- 53 select '6+ (4108+)' BUCKET,
- 54 KSMCHCLS,
- 55 KSMCHIDX,
- 56 1000 * trunc(KSMCHSIZ / 1000),
- 57 count(*),
- 58 max(KSMCHSIZ),
- 59 trunc(avg(KSMCHSIZ)) "AvgSize",
- 60 trunc(sum(KSMCHSIZ)) "Total"
- 61 from x$ksmsp
- 62 where KSMCHSIZ >= 4108
- 63 and KSMCHCLS = 'free'
- group by KSMCHCLS, KSMCHIDX, 1000 * trunc(KSMCHSIZ / 1000)
- 64 65 /
- BUCKET KSMCHCLS KSMCHIDX From Count Biggest AvgSize Total
- -------------- -------- ---------- ---------- ---------- ---------- ---------- ----------
- 0 (<140) free 1 110 10 112 112 1120
- 0 (<140) free 1 50 4 56 56 224
- 0 (<140) free 1 80 9 88 85 768
- 0 (<140) free 1 70 5 72 72 360
- 0 (<140) free 1 40 36 48 44 1616
- 0 (<140) free 1 120 13 128 123 1608
- 0 (<140) free 1 60 10 64 64 640
- 0 (<140) free 1 90 3 96 96 288
- 0 (<140) free 1 130 18 136 136 2448
- 0 (<140) free 1 100 6 104 104 624
- 1 (140-267) free 1 200 31 216 202 6280
- 1 (140-267) free 1 220 47 232 230 10824
- 1 (140-267) free 1 240 13 256 246 3200
- 1 (140-267) free 1 140 16 152 148 2368
- 1 (140-267) free 1 260 7 264 264 1848
- 1 (140-267) free 1 160 97 176 165 16080
- 1 (140-267) free 1 180 27 192 189 5128
- 2 (268-523) free 1 450 28 496 480 13448
- 2 (268-523) free 1 300 26 344 327 8504
- 2 (268-523) free 1 400 35 448 419 14688
- 2 (268-523) free 1 350 54 392 377 20392
- 2 (268-523) free 1 500 20 520 510 10216
- 2 (268-523) free 1 250 22 296 284 6256
- 3-5 (524-4107) free 1 2500 64 2992 2783 178128
- 3-5 (524-4107) free 1 1500 69 1992 1732 119576
- 3-5 (524-4107) free 1 2000 84 2488 2266 190344
- 3-5 (524-4107) free 1 3500 160 3992 3720 595280
- 3-5 (524-4107) free 1 500 38 552 535 20344
- 3-5 (524-4107) free 1 4000 28 4080 4048 113360
- 3-5 (524-4107) free 1 3000 163 3496 3319 541072
- 3-5 (524-4107) free 1 1000 28 1496 1475 41304
- 6+ (4108+) free 1 18000 34 18920 18481 628376
- 6+ (4108+) free 1 40000 3 40848 40514 121544
- 6+ (4108+) free 1 9000 84 9992 9419 791248
- 6+ (4108+) free 1 13000 56 13976 13447 753072
- 6+ (4108+) free 1 21000 18 21936 21571 388280
- 6+ (4108+) free 1 32000 2 32992 32516 65032
- 6+ (4108+) free 1 52000 2 52456 52400 104800
- 6+ (4108+) free 1 17000 26 17824 17351 451136
- 6+ (4108+) free 1 59000 1 59856 59856 59856
- 6+ (4108+) free 1 50000 2 50376 50232 100464
- 6+ (4108+) free 1 19000 25 19888 19518 487968
- 6+ (4108+) free 1 23000 22 23920 23395 514696
- 6+ (4108+) free 1 15000 41 15976 15480 634720
- 6+ (4108+) free 1 31000 6 31784 31497 188984
- 6+ (4108+) free 1 43000 1 43192 43192 43192
- 6+ (4108+) free 1 5000 116 5992 5397 626152
- 6+ (4108+) free 1 6000 88 6992 6497 571736
- 6+ (4108+) free 1 30000 3 30712 30552 91656
- 6+ (4108+) free 1 24000 22 24984 24493 538864
- 6+ (4108+) free 1 64000 1 64688 64688 64688
- 6+ (4108+) free 1 38000 3 38776 38440 115320
- 6+ (4108+) free 1 47000 2 47928 47520 95040
- 6+ (4108+) free 1 4000 155 4976 4447 689304
- 6+ (4108+) free 1 14000 60 14992 14559 873552
- 6+ (4108+) free 1 39000 2 39864 39672 79344
- 6+ (4108+) free 1 35000 2 35600 35400 70800
- 6+ (4108+) free 1 34000 2 34800 34684 69368
- 6+ (4108+) free 1 36000 2 36544 36528 73056
- 6+ (4108+) free 1 11000 99 11968 11505 1139072
- 6+ (4108+) free 1 10000 66 10944 10520 694376
- 6+ (4108+) free 1 22000 20 22936 22395 447912
- 6+ (4108+) free 1 28000 9 28816 28359 255232
- 6+ (4108+) free 1 26000 11 26640 26328 289616
- 6+ (4108+) free 1 44000 2 44528 44368 88736
- 6+ (4108+) free 1 37000 3 37464 37160 111480
- 6+ (4108+) free 1 42000 2 42072 42064 84128
- 6+ (4108+) free 1 8000 201 8992 8491 1706776
- 6+ (4108+) free 1 7000 133 7992 7510 998840
- 6+ (4108+) free 1 25000 20 25960 25420 508400
- 6+ (4108+) free 1 20000 20 20960 20547 410952
- 6+ (4108+) free 1 27000 8 27984 27460 219680
- 6+ (4108+) free 1 29000 8 29952 29491 235928
- 6+ (4108+) free 1 46000 1 46832 46832 46832
- 6+ (4108+) free 1 12000 7894 12992 12598 99451552
- 6+ (4108+) free 1 53000 2 53448 53404 106808
- 6+ (4108+) free 1 16000 57 16928 16476 939144
- 6+ (4108+) free 1 33000 3 33872 33493 100480
- 6+ (4108+) free 1 41000 2 41296 41224 82448
复制代码
可以看到 flush shared_pool之后 bucket 0 (<140) 中的小chunk明显变少 ,
而 bucket 6+ (4108+) 的 大尺寸 memory chunk 明显增加 ,说明 在 flush out freeable 和 unpinned recreatable chunk 后, FREE LIST上确实发生合并(coalesce), 多个小的连续的free chunk 可以合并成较大的 free chunk。
SQL> oradebug setmypid;
Statement processed.
SQL> oradebug dump heapdump 536870914;
Statement processed.
SQL> oradebug tracefile_name;
/s01/admin/G10R21/udump/g10r21_ora_4541.trc
直接观察 FREE LIST也可以发现这一点:
- REE LISTS:
- Bucket 0 size=32
- Bucket 1 size=40
- Chunk 080c517b0 sz= 40 free " "
- Chunk 07f7a3b10 sz= 40 free " "
- Chunk 07f444340 sz= 40 free " "
- Chunk 08095b458 sz= 40 free " "
- Chunk 07f8765b8 sz= 40 free " "
- Chunk 0801f0300 sz= 40 free " "
- Chunk 080d2a9b0 sz= 40 free " "
- Chunk 07f69cd90 sz= 40 free " "
- Chunk 080d52bd8 sz= 40 free " "
- Chunk 07f8f8788 sz= 40 free " "
- Chunk 07f1b3ee0 sz= 40 free " "
- Chunk 07ef98bd8 sz= 40 free " "
- Chunk 080151360 sz= 40 free " "
- Chunk 0810a5068 sz= 40 free " "
- Chunk 080657200 sz= 40 free " "
- Chunk 0801e0f88 sz= 40 free " "
- Chunk 0807ec3c8 sz= 40 free " "
- Chunk 07fa767f0 sz= 40 free " "
- Chunk 0810d3fd0 sz= 40 free " "
- Chunk 080119dc0 sz= 40 free " "
- Chunk 080fa3678 sz= 40 free " "
- Chunk 081108140 sz= 40 free " "
- Chunk 081f30f28 sz= 40 free " "
- ............................
- MORE LARGE FREE CHUNK Below:
复制代码 |
|