Oracle dirty block的一些探讨(四)
继续探讨Oracle dirty话题,前面一直用到了alter system flush_cache命令。
那alter system checkpoint和alter system flush buffer_cache有什么区别? 一个简单的测试可以看出些端倪。
打开SQLPUS 会话状态信息统计功能,可以看到对zhoul表格读取全部执行8个consistent gets,也就意味着表格全部在buffer cache中
SQL> set autot traceonly stat
SQL> select * from zhoul;
Statistics
----------------------
0 recursive calls
0 db block gets
8 consistent gets
0 physical reads
0 redo size
517 bytes sent via SQL*Net to client
400 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
3 rows processed
执行alter system checkpoint之后,可以看到表格读取依然执行8个consistent gets,也就意味着执行全量增量点后,dirty block在写数据文件的同时,内存并不清空。
SQL> alter system checkpoint;
System altered.
SQL> select * from zhoul;
Statistics
----------------------
0 recursive calls
0 db block gets
8 consistent gets
0 physical reads
0 redo size
517 bytes sent via SQL*Net to client
400 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
3 rows processed
在执行flush buffer_cache之后,可以看到业务表格zhoul读取出现6个physical reads,也就意味着执行flush buffer_cache,Oracle会将buffer cache清空。
SQL> alter system flush buffer_cache;
System altered.
SQL> select * from zhoul;
Statistics
----------------------
0 recursive calls
0 db block gets
8 consistent gets
6 physical reads
0 redo size
517 bytes sent via SQL*Net to client
400 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
3 rows processed