单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


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