db_block,consistent gets

Oracle accesses blocks in one of two modes, current or consistent.

A ‘db block get’ is a current mode get. That is, it’s the most up-to-date
copy of the data in that block, as it is right now, or currently. There
can only be one current copy of a block in the buffer cache at any time.
Db block gets generally are used when DML changes data in the database.
In that case, row-level locks are implicitly taken on the updated rows.
There is also at least one well-known case where a select statement does
a db block get, and does not take a lock. That is, when it does a full
table scan or fast full index scan, Oracle will read the segment header
in current mode (multiple times, the number varies based on Oracle version).

A ‘consistent get’ is when Oracle gets the data in a block which is consistent
with a given point in time, or SCN. The consistent get is at the heart of
Oracle’s read consistency mechanism. When blocks are fetched in order to
satisfy a query result set, they are fetched in consistent mode. If no
block in the buffer cache is consistent to the correct point in time, Oracle
will (attempt to) reconstruct that block using the information in the rollback
segments. If it fails to do so, that’s when a query errors out with the
much dreaded, much feared, and much misunderstood ORA-1555 “snapshot too old”.
db_block_gets:当前请求的块数量
也称为current_mode,一般发生在dml(update,insert,delete)
只读取当前时间点最新块的数据,当前时间点读到什么就是什么,不具备数据时间点一致性
假定更新一个大表过程中,有一个进程修改了最后一条记录,当大表更新抵达的时候,会阻塞,
若改进程修改提交,则大表更新会覆盖此更新(大表更新会在进程修改的基础上再修改)

consistent_gets:数据请求总数在回滚段buffer中的数据一致性所需要数据块数量
是oracle在查询开始的时候,所获得的数据必须是在时间点上一致的。
假定查询开始的时候所有数据都是已经提交的,查询开始之后,若数据发生了变化,
则查询需要去从回滚段中获得变化前的数据,而若数据没有发生变化,则不用去回滚段中读了。
不管是否去回滚段中读,在概念上来讲,这种数据获取方式都叫 consistent gets 。
这仅仅表示一种期望,需要获得一致的时间点的数据,为此可能需要去回滚段中获得数据但并不表示一定从回滚段中的到数据

也称为query_mode, 一般在查询时产生(select)

补充:
current mode 和query mode 只不过是2种相对的不同的叫法。对于select 来说,由于oracle 的读一致性特性,
在query mode 下,oracle 从buffer cache 中读到的数据必须是一致的,所以在query mode 下,oracle 可能或者不需要从undo 中读取数据,
所以在query mode 下,就是consistents gets,所以在select 中一般只有consistent gets 而没有db block gets

而对于DML(insert,delete,update)操作,因为是修改数据就不需要什么一致性读了,就是直接在buffer cache 里面进行修改了,
所以叫做current mode ,就是当前读到什么数据就修改,不需要保证数据库的一致性,因为修改都要将数据进行修改,修改呢?
也是在buffer cache 中完成的,所以就叫做current mode ,为了和query 区别,对Buffer 的访问就叫做db block 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))

consistent gets读取就是从buffer中读,至于没有进行BUFFER的数据块,他会进行缓存,我们只能说此时的consistent gets引起了磁盘IO,所有要读取的数据块,还都是要经过缓存的,每个consistent gets都会引起latch,这也许是TOM强调调整时关注逻辑读的原因

consistent gets
表示的是对一个数据获取时进行一致性读的次数,注意不是当前读,也就是在data buffer块中没有找到,需要根据该数据的前影像来构建CR块来完成一致性读过程,进行DML操作必须要用到一致性读,当然这并非只是唯一的情况,只要不能进行当前读的操作就可能会是一致性读,一致性读还不能获取数据,那就只能是物理读了。
————————————————
版权声明:本文为CSDN博主「winer1220」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/winer1220/article/details/11966309

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值