这两个概念一直没搞懂 db_blocks_gets & consistent_gets

[复制链接]
查看11 | 回复4 | 2005-2-28 12:57:00 | 显示全部楼层 |阅读模式
Oracle collects statistics on data access and stores them in the dynamic performance
table V$SYSSTAT. You measure the cache hit ratio using three system statistics:
? db block gets: Accesses to the current image of a block
? consistent gets: Accesses to a read-consistent image of a block
? physical reads: Number of blocks read from disk
Calculate the hit ratio for the buffer cache with this formula:
Hit Ratio = 1 – (physical reads/(db block gets + consistent gets))
Adding db_blocks_gets and consistent_gets gives the total number of requests
for data. This value includes requests satisfied by access to buffers in memory and
requests that cause a physical I/O. You can multiply the ratio by 100 to convert to a
percentage.
我的理解是:
db_blocks_gets是 query 得到的所有data blocks的数目
consistent_gets是 除了 query 之外的其他操作而得到 data blocks的数目,比如insert,update
physical reads是 从磁盘 读到的 data blocks 数量,而且只算 Input,不算Output
可我总觉得不太对劲,希望各位能释疑,谢谢
另外,比如我要insert 一条纪录的时候,这个 oracle的工作过程是怎样的?
回复

使用道具 举报

千问 | 2005-2-28 12:57:00 | 显示全部楼层
db_blocks_gets是从表中直接读到的,consistent_gets是从回滚段中读到的前映(或叫读取一致性影象),两者之和就是物理读的总量,你的看法不对。
回复

使用道具 举报

千问 | 2005-2-28 12:57:00 | 显示全部楼层
db_blocks_gets是从db_buffer_cache中读取的部分
consistent_gets在其它用户修改数据后从回滚段的before image中读取
physical reads是从磁盘读取
回复

使用道具 举报

千问 | 2005-2-28 12:57:00 | 显示全部楼层
好象不太正确,我做了一下这个实验,
SQL> select NAME,VALUE from V$SYSSTAT
2where name in('db block gets','consistent gets');
NAME
VALUE
---------------------------------------------------------------- ----------
db block gets
68856
consistent gets
408998
SQL> select * from scott.aa; //这个表我之前没访问过
C1 C2
---------- ----------
1 10
1 10
2 20
2 20
SQL> select NAME,VALUE from V$SYSSTAT
2where name in('db block gets','consistent gets');
NAME
VALUE
---------------------------------------------------------------- ----------
db block gets
68884
consistent gets
409062
aa这个表我之前没访问过,即没可能从ROLLBACK SEGMENT 中读出,但consistent gets 的值增加得比db block gets 还要多!这又怎么解释?
回复

使用道具 举报

千问 | 2005-2-28 12:57:00 | 显示全部楼层
Oracle文档:
db block gets: Accesses to the current image of a block
consistent gets: Accesses to a read-consistent image of a block
physical reads: Number of blocks read from disk
Hit Ratio = 1 – (physical reads/(db block gets + consistent gets))
我的理解:
db block gets: 获取数据的当前映像所读取的数据块。
Oracle为了获取数据的当前映像,会先去数据缓存(Data cache)中找,如果有就直接读取(逻辑读),如果没有再去数据文件中读取(物理读)。
consistent gets: 获取数据的读一致性映像所读取的数据块。
应该仅发生在用户查询时该数据块正在被修改的情况下,则数据的前映像在回滚段中,Oracle为了获取一致性映像,必须从回滚段中读取(物理读)。
physical reads: 所有物理读的总数。
从而: db block gets + consistent gets 就是所有读取操作涉及的数据块
则物理读在所有读操作中所占的比例就是:
physical reads/(db block gets + consistent gets)
数据高速缓存的命中率就应该是:
Hit Ratio = 1 – (physical reads/(db block gets + consistent gets))
请高人斧正!谢谢
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行