consistent gets 与consistent read
////////////////////////////////////////////////////////////////////////////////////////////////////
Part 1:
Consistent Gets,Physical Reads和DB Block Gets的解释 分类:Oracle调优/深入 2007.8.29 11:29 作者:digifish | 评论:1 | 阅读:3161
在Oracle的文档中有这样的解释:
db block gets:Number of times a CURRENT block was requested.
consistent gets:Number of times a consistent read was requested for a block.
physical reads:Total number of data blocks read from disk. This number equals the value of "physical reads direct" plus all reads into buffer cache.
---------------------------------------------
针对以上3个概念进行的说明解释及关系如下:
1、DB Block Gets(当前请求的块数目)
当前模式块意思就是在操作中正好提取的块数目,而不是在一致性读的情况下而产生的块数。正常的情况下,一个查询提取的块是在查询开始的那个时间点上存在的数据块,当前块是在这个时刻存在的数据块,而不是在这个时间点之前或者之后的数据块数目。
2、Consistent Gets(数据请求总数在回滚段Buffer中的数据一致性读所需要的数据块)
这里的概念是在处理你这个操作的时候需要在一致性读状态上处理多少个块,这些块产生的主要原因是因为由于在你查询的过程中,由于其他会话对数据块进行操作,而对所要查询的块有了修改,但是由于我们的查询是在这些修改之前调用的,所以需要对回滚段中的数据块的前映像进行查询,以保证数据的一致性。这样就产生了一致性读。
不过精确翻译来说,前两个不是块数而是IO请求次数,不过对于这两者应该是一次读一块的。
3、Physical Reads(物理读)
就是从磁盘上读取数据块的数量,其产生的主要原因是:
1、 在数据库高速缓存中不存在这些块
2、 全表扫描
3、 磁盘排序
它们三者之间的关系大致可概括为:
逻辑读指的是Oracle从内存读到的数据块数量。一般来说是'consistent gets' + 'db block gets'。当在内存中找不到所需的数据块的话就需要从磁盘中获取,于是就产生了'phsical reads'。
-----------------------------------------
· DB Block Gets. Number of times a CURRENT block was requested.
Current mode blocks are retrieved as they exist right now, not in a consistent read fashion. Normally, blocks retrieved for a query are retrieved as they existed when the query began. Current mode blocks are retrieved as they exist right now, not from a previous point in time. During a SELECT, you might see current mode retrievals due to reading the data dictionary to find the extent information for a table to do a full scan (because you need the "right now" information, not the consistent read). During a modification, you will access the blocks in current mode in order to write to them.
· Consistent Gets. Number of times a consistent read was requested for a block.
This is how many blocks you processed in "consistent read" mode. This will include counts of blocks read from the rollback segment in order to roll back a block. This is the mode you read blocks in with a SELECT, for example. Also, when you do a searched UPDATE/DELETE, you read the blocks in consistent read mode and then get the block in current mode to actually do the modification.
-----------------------------------------------
DB Block Gets. 当前块被请求的次数。
当存在时,当前模式块将被立即检索,而不会以一致读的方式检索。通常,查询检索的块如果在查询开始时存在,它们就被检索。当前模式块如果存在就立即被检索,而不是从一个以前的时间点检索。在一个SELECT期间,你可以看到当前模式检索,因为对于需要进行全面扫描的表来说,需要读数据字典来找到范围信息(因为你需要"立即"信息,而不是一致读)。在修改期间,为了向块中写入内容,你要以当前模式访问块。
· Consistent Gets. 对于一个块一致读被请求的次数。
这是你以"一致读"模式处理的块数。为了回滚一个块,这将包括从回滚段读取的块的数目。例如,这是你在SELECT语句中读取块的模式。当你进行一个指定的UPDATE/DELETE操作时,你也以一致读模式读取块,然后以当前模式获得块以便实际进行修改。
----
要注意Oracle 的physical read 与 physical writes并不总是等于硬盘真正意义上的物理读与物理写,因为现在都存在操作系统高速缓存与磁盘子系统高速缓存,这样即使I/O没有被实际写入磁盘,操作系统I/O子系统或磁盘系统也会确认为一个成功的I/O,所以ORACLE 的physical read 与 physical writes并不是物理上发生读写的次数。
////////////////////////////////////////////////////////////////////////////////////////////////////
Part 2:
不需用想太复杂。
我8点开始跑一个查询,8点20分访问到一个block(这个访问当然是一致模式的访问),
那我要查一下这个Block头信息,
情况一是,如果这个block的上一次改变在8点10分发生,那我就需要去读undo(或者读内存里的一致块),
情况二是,如果这个Block的最后一次改变时7点59分,那我就直接读这个block。
即使对情况一,也有不同情况:
大致是这样的:
如果block在8点10分被修改了一次,oracle会在内存里建立8点10分一致块a(这个一致块是8点10分之前的版本),
如果block在8点11分被修改了一次,oracle会在内存里建立8点11分一致块b(这个一致块是8点10分的版本),
如果block在8点12分被修改了一次,oracle会在内存里建立8点12分一致块c(这个一致块是8点11分的版本),
如果block在8点13分被修改了一次,oracle会在内存里建立8点13分一致块d(这个一致块是8点12分的版本),
如果block在8点14分被修改了一次,oracle会在内存里建立8点14分一致块e(这个一致块是8点13分的版本),
如果block在8点15分被修改了一次,oracle会在内存里建立8点15分一致块f(这个一致块是8点14分的版本),
如果block在8点16分又被修改了一次,oracle会在内存里建立8点16分一致块g,但是维护太多一致块也是很烦的,所以oracle只保留6个一致块,所以这时候8点10分建立的一致块会被冲掉, 现在这个block在内存里的一致块就是b~g.
然后,还是前面8点开始的查询,8点20分访问到这个block的时候,我们需要的是8点10分之前的版本,也就是版本a,在cache里已经没有了,这时不得不读Undo, 否则,如果a还在的话,直接读a就可以了。
分享到:
相关推荐
arraysize对consistent gets的影响
oracle数据库 oracle数据库的性能调整 性能调整
开源项目-lafikl-consistent.zip,lafikl/consistent: a package for Consistent Hashing and Consistent Hashing With Bounded Loads.
Nginx:一致性哈希(第三方模块ngx_http_consistent_hash):ngx_http_consistent_hash-master.zip
Consistent Hashing and Random Trees
开源项目-buraksezer-consistent.zip,go中有界负载的一致散列
Consistent-hashing: Go中的散列环实现
Consistent Global States of Distributed Systems
Jemter测试MQ的插件 JMeter-Rabbit-AMQP在github上17年便停止更新了,不支持rabbitmq的交换机类型“x-consistent-hash”,为此我更改了源码使其支持"x-consistent-hash
analysis, we propose a novel, real-time EKF-based VIO algorithm, which achieves consistent estimation by (i) ensuring the correct observability properties of its linearized system model, and (ii) ...
Applications of self-consistent field theory in polymer systems.pdf
CVPR2015-Cross-modality Consistent Regression for Joint Visual-Textual Sentiment Analysis.pdf 全文
python库。 资源全名:ConsistentHashing-0.1.9.tar.gz
目标检测论文 Consistent Optimization for Single-Shot Object Detection.pdf
libconhash is a consistent hashing libraray, which can be compiled both on Windows and Linux platform. High performance, easy to use, and easy to scale according to node's processing capacity.
资源分类:Python库 所属语言:Python 资源全名:jump_consistent_hash-3.1.1-cp27-cp27m-win_amd64.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
this the problem of consistent labeling of objects when seen in multiple cameras. We employ a novel approach of finding the limits of field of view (FOV) of each camera as visible in the other cameras...
It is a challenging task to read the balance sheet of an insurance company. This derives from the fact that different positions are often measured by different yardsticks. Assets, for example, are ...
Building reliable distributed systems at a worldwide scale demands trade-offs between consistency and availability.
mongodb_consistent_backup, 对MongoDB集群或者副本集执行一致备份的工具 一致性备份工具- mongodb-consistent-backup 使用可选的归档,压缩/复制,加密和上传功能,为MongoDB创建一致的point-in-time备份这个工具的...