單session下的cr塊的產生

一.Update 無索引(全表掃描)
Select * from test;
1    TEST    xcur    12    34    6B568000
2    TEST    xcur    12    33    6B644000

Update test set name = ‘001’ where id > ‘000’;
1    TEST    xcur    12    34    6B484000
2    TEST    xcur    12    33    6B644000
3    TEST    cr        12    34    6B568000   ===> xcur-> cr
注意:此時表沒有索引,執行的全表掃描的update


二.Update 有索引(索引掃描)
Create index ind_test on test(id);
Select * from test;
1    TEST    xcur    12    33    6B1B8000
2    TEST    xcur    12    34    6B3E0000

Update test set name = ‘001’ where id > ‘000’;
1    TEST    xcur    12    33    6B1B8000
2    TEST    xcur    12    34    6B3E0000

結論1,由此可見單獨的select不會產生cr。在索引掃描情況下的update也不會產生cr。僅僅當全表掃描的update的時候纔會產生cr。


三.Insert
Insert into test values (‘006,’’sunwg’);
1    TEST    xcur    12    33    6B3C8000
2    TEST    xcur    12    34    6BFA6000

結論2,在insert的時候不會產生cr,所有塊均爲當前塊xcur。


四.Delete無索引(全表掃描)
Select * from test;
1    TEST    xcur    12    33    6ADE4000
2    TEST    xcur    12    34    6BB76000
Delete from test where id > ‘001’;
1    TEST    xcur    12    33    6ADE4000
2    TEST    xcur    12    34    6BC12000
3    TEST    cr        12    34    6BB76000   ===> xcur-> cr


五.Delete有索引(索引掃描)
Select * from test;
1    TEST    xcur    12    34    6B2AC000
2    TEST    xcur    12    33    6BE40000
Delete from test where id > ‘001’;
1    TEST    xcur    12    34    6B2AC000
2    TEST    xcur    12    33    6BE40000

結論3,在索引掃描情況下的delete也不會產生cr。僅僅當全表掃描的delete的時候纔會產生cr。


六.Insert select 無索引
Select * from test;
1    TEST    xcur    12    33    6B2AC000
2    TEST    xcur    12    34    6BD8A000
Insert into test select * from test;
1    TEST    xcur    12    33    6B2AC000
2    TEST    xcur    12    34    6BD8A000


七.Insert select 有索引
Select * from test;
1    TEST    xcur    12    33    6AF8C000
2    TEST    xcur    12    34    6BD56000
Insert into test select * from test;
1    TEST    xcur    12    33    6AF8C000
2    TEST    xcur    12    34    6BD56000

結論4,Insert select不會產生cr

附錄:
Select o.object_name
,decode(state,0,'free',1,'xcur',2,'scur',3,'cr', 4,'read',5,'mrec'
,6,'irec',7,'write',8,'pi') state
, dbarfil, dbablk, ba
from x$bh b , dba_objects o
where b.obj = o.data_object_id
and b.ts# > 0
and o.object_name = 'TEST'
group by o.object_name, state, blsiz
, ba, dbarfil, dbablk


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章