`

consistent get,db block get

 
阅读更多

Link:http://h11h99.blog.51cto.com/230273/42860

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".
As to latching, and how it relates, well, consider that the block buffers
are in the SGA, which is shared memory. To avoid corruption, latches are
used to serialize access to many linked lists and data structures that point
to the buffers as well as the buffers themselves. It is safe to say that
each consistent get introduces serialization to the system, and by tuning
SQL to use more efficient access paths, you can get the same answer to the
same query but do less consistent gets. This not only consumes less CPU,
it also can significantly reduce latching which reduces serialization and
makes your system more scalable.

buffer_gets=db block gets + consistent gets = LOGIC IO(逻辑读次数).

consistent gets : 通过不带for update的select 读的次数
db block gets : 通过update/delete/select for update读的次数.

consistent get : 在一致读模式下所读的快数,包括从回滚段读的快数。
db block gets : 在当前读模式下所读的快数,比较少和特殊,例如数据字典数据获取,在DML中,更改或删除数据是要用到当前读模式。

consistent gets :consistent_gets是从回滚段中读到的前映(或叫读取一致性影象), 看见的数据是查询开始的时间点的,所以若存在block在查询开始后发生了变化的情况,则必须产生 before image 然后读数据,这就是一致读的含义
查询就是表示 consistent gets (query mode),因为查询要保证所获取的数据的时间点的一致性,所以叫一致读,即使是从当前 buffer 获得的数据,也叫 consistent gets ,这仅仅表达一种模式一种期望,并不表示真实的是从 当前buffer 获得 还是从回滚段获取数据产生的 bufore image 。

db block gets : current mode , 不管这个块上的数据是否可能存在 before image ,也就是说不管是否存在回滚中数据可以 回滚,只看见当前最新块的数据,即使别人正在更新,也看见别人更新状态的数据,比如dml的时候就不需要看见别人更改前的数据,而是看见正在更改的,当然同时,若操作相同数据则被lock住。也就是说一次查询中看见的数据可能不在同一个时间点上,比如一个大的dml,当dml 开始更新一个非常大的表后,这个表更新的过程中,有一个进程去把该表末尾的一个记录更新了,然后这个大更新抵达该记录的时候会被阻塞的,若该进程事物提交,则大更新会覆盖该事务的更新,也就是说,这个大更新所看见的数据是当前的,不具有时间点的一致性,所以叫 current mode,个人认为db block gets这个词用的不好, 容易让人误解. 如果改成inconsistent gets可能会更准确一些

consistent gets
db block gets + consistent gets = logical io (as opposed to physical io). consistent gets are current mode gets. This might entail a reconstruction of the block with the undo (rollback) mechanism.

Number of times a consistent read was requested for a block.

db block gets
db block gets + consistent gets = logical io (as opposed to physical io). db block gets are current mode gets, blocks that are read as they are (even if these are being modified by another session)

Number of times a CURRENT block was requested

Oracle Metric consistent gets

Oracle Tips by Burleson Consulting

The consistent gets Oracle metric is the number of times a consistent read (a logical RAM buffer I/O) was requested to get data from a data block. Part of Oracle tuning is to increase logical I/O by reducing the expensive disk I/O (physical reads), but high consistent gets presents it's own tuning challenges, especially when we see super high CPU consumption (i.e. the "top 5 timed events" in an AWR report).

Tuning Consistent Gets

Many shops with super-high consistent gets have high CPU consumption and this is quickly fixed by adding more CPU's to the server. Note that Oracle expert Kevin Closson sees "buffer chains latch" thrashing (latch overhead) as a major contributor to high CPU consumption on highly-buffered Oracle databases (e.g. 64-bit Oracle with a 50 gig db_cache_size):

" The closer a system gets to processor saturation, the more troublesome latch gets become--presuming the chain is hot.

While cache buffers chains latch thrashing may seem like a nebulous place to put blame for high processor utilization, trust me, it isn't.".

Types of Consistent Gets

Not all buffer touches are created equal, and Oracle has several types of "consistent gets", the term used by Oracle to describe an Oracle I/O that is done exclusively from the buffer cache. Oracle AWR and STATSPACK reports mention several types of consistent gets, all undocumented:

consistent gets

consistent gets from cache

consistent gets - examination

consistent gets direct

Some Oracle experts claim that these undocumented underlying mechanism can be revealed and that these consistent gets metrics may tell us about data clustering Mladen Gogala, author of "Easy Oracle PHP" makes these observations about consistent gets:

"The [consistent gets] overhead is the time spent by Oracle to maintain its own structures + the time spent by OS to maintain its own structures. So, what exactly happens during a consistent get in the situation described? As I don't have access to the source code, I cannot tell precisely, with 100% of certainty, but based on my experience, the process goes something like this:

1) Oracle calculates the hash value of the block and searches the SGA hash table for the place where the block is located.

2) Oracle checks the SCN of the block and compares it with the SCN of the current transaction. Here, I'll assume that this check will be OK and that no read consistent version needs to be constructed.

3) If the instance is a part of RAC, check the directory and see whether any other instance has modified the block. It will require communication with the GES process using the IPC primitives (MSG system calls). MSG system calls are frequently implemented using device driver which brings us to the OS overhead (context switch, scheduling)

4) If everything is OK, the block is paged in the address space of the requesting process. For this step I am not exactly sure when does it happen, but it has to happen at some point. Logically, it would look as the last step, but my logic may be flawed. Here, of course, I assume a soft fault. Hard fault would mean that a part of SGA was swapped out.

All of this is an overhead of a consistent get and it is the simplest case. How much is it in terms of microseconds, depends on many factors, but the overhead exists and is strictly larger then zero. If your SQL does a gazillion of consistent gets, it will waste significant CPU power and time to perform that."

For more insights on consistent gets, we see expert Kevin Closson who has a great description of the internal mechanisms within consistent gets. Kevin goes on to describe the internals of a consistent get:

"The routine is kcbget() (or one of his special purpose cousins). It doesn't really "search" a hash *table* if you will. A hash table would be more of a "perfect hash" structure and to implement that, every possible hash value has to be known when the table is set up. That would mean knowing every possible database block address.

Instead, it hashes to a bucket that has similar hashed dbas chained off off it in a linked list. So it is more of a scan of the linked list looking for the right dba and right version of it.

The particulars of the structures under a get are not as important as remembering that before walking that chain, the process has to obtain the latch on the chain. "

Consistent gets - examination

Mike Ault notes that "consistent gets - examinations" are related to buffer management overhead and data access overhead such as index reads and undo writes:

"consistent gets – examination is from reading something like undo blocks…

Other examples of "consistent gets – examination" are: reading the root block of an index, reading an undo block while creating a consistent read data block, reading a block in a single table hash cluster - unless it is found to have the ‘collision flag’ set."

Steve Karam, OCM notes about "consistent gets - examination":

"Consistent gets - examination are a different kind of consistent get that only requires a single latch, saving CPU. The most common use of a consistent get - examination is to read undo blocks for consistent read purposes, but they also do it for the first part of an index read and in certain cases for hash clusters.

So if you're doing a query on a couple tables that are mostly cached, but one of them has uncommitted DML against it at the time, you'll do consistent gets for the standard data in the cache, and the query will do consistent gets - examination to read the undo blocks and create read consistent blocks; this doesn't necessarily save CPU unfortunately, because while the consistent gets - examination only acquire one latch, creating the read consistent data block also takes a latch.

However, I think that when you use single table hash clusters (or the new 10g Sorted Hash Clusters I mentioned once that automatically sort by a key so they don't need order by) you can get a performance gain, because reads from the blocks of a hash cluster are usually consistent get - examination, therefore they only need one latch instead of two. "

Interpreting consistent gets in reports

Here is a STATSPACK (pr AWR) report we see displays for "consistent gets" and "consistent gets - examinations":

Statistic Total per Second per Trans

--------------------------------- ------------------ -------------- -----------

consistent gets 35,024,284 9,718.2 3,703.9

consistent gets - examination 12,148,672 3,370.9 1,284.8

The consistent gets from cache Oracle metric is the number of times a consistent read was requested for a block from the buffer cache.

set pages 999 set lines 92 ttitle 'Contents of Data Buffers' drop table t1; create table t1 as select o.owner owner, o.object_name object_name, o.subobject_name subobject_name, o.object_type object_type, count(distinct file# || block#) num_blocks from dba_objects o, v$bh bh where o.data_object_id = bh.objd and o.owner not in ('SYS','SYSTEM') and bh.status != 'free' group by o.owner, o.object_name, o.subobject_name, o.object_type order by count(distinct file# || block#) desc ;

from:

http://xgss2000.blog.163.com/blog/static/2328860820094110648909/

分享到:
评论

相关推荐

    Consistent Hashing and Random Trees

    Consistent Hashing and Random Trees

    开源项目-lafikl-consistent.zip

    开源项目-lafikl-consistent.zip,lafikl/consistent: a package for Consistent Hashing and Consistent Hashing With Bounded Loads.

    开源项目-buraksezer-consistent.zip

    开源项目“buraksezer-consistent.zip”是一个基于Go语言实现的一致性哈希算法库。一致性哈希是一种分布式计算中的重要算法,主要用于解决在分布式集群中如何均匀地分配键值到各个节点的问题,尤其在动态添加或移除...

    ngx_http_consistent_hash-master.zip

    "ngx_http_consistent_hash-master.zip" 是一个与 Nginx Web服务器相关的压缩包文件,其中包含了一个名为 "ngx_http_consistent_hash" 的第三方模块的源代码。"master" 指示这可能是该模块的主分支或最新版本。 **...

    Python库 | ConsistentHashing-0.1.9.tar.gz

    而`ConsistentHashing-0.1.9.tar.gz`这个压缩包文件则包含了一个名为`ConsistentHashing`的Python库,版本为0.1.9。这个库主要涉及到一致性哈希(Consistent Hashing)算法,它在分布式系统和负载均衡中扮演着重要...

    Go-Consistent-hashing:Go中的散列环实现

    一致性哈希(Consistent Hashing)是一种在分布式系统中解决数据分片问题的算法,它在Go语言中的实现对于构建可扩展且容错的服务至关重要。在Go开发中,尤其是在涉及分布式缓存、负载均衡等场景下,一致性哈希能够...

    Consistent hashing

    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.

    SQL Server 数据库的优化及保护.pdf

    计算高速缓冲区命中率的公式为:Hit Ratio = 1 - (physical reads / (db block gets + consistent gets))。对于一般环境,命中率要求大于80%,而在UNIX环境下使用RAW DEVICE时,要求更高,需大于90%。如果命中率低于...

    Jemter JMeter-Rabbit-AMQP插件升级版,支持rabbitmq交换机类型“x-consistent-hash”

    Jemter测试MQ的插件 JMeter-Rabbit-AMQP在github上17年便停止更新了,不支持rabbitmq的交换机类型“x-consistent-hash”,为此我更改了源码使其支持"x-consistent-hash

    逻辑读写深入分析.pdf

    - **`consistent gets`**:这是除`db block gets`外其他所有逻辑读的统称,包括对表、索引的数据块读取以及为了确保数据一致性而对UNDO数据块的读取。 ##### 2. 统计数据来源 Oracle通过一系列视图如`v$sysstat`、`...

    High-Precision, Consistent EKF-based Visual-Inertial Odometry.pdf

    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

    自我一致场理论(Self-Consistent Field Theory,SCFT)作为一种理论模型,在聚合物科学领域发挥着至关重要的作用。随着对复杂体系中微观结构与宏观性质关联的深入探索,SCFT为我们提供了一个强有力的工具,用于理解...

    Eventual-Consistent

    Building reliable distributed systems at a worldwide scale demands trade-offs between consistency and availability.

    DB2查看数据库配置

    23. 数据库是一致的(DATABASE_CONSISTENT):该参数显示当前数据库的一致性设置,例如NO表示数据库不一致。 24. 前滚暂挂(ROLLFORWARD_PENDING):该参数显示当前数据库的前滚暂挂设置,例如NO表示不暂挂前滚。 ...

    Crossmodality Consistent Regression for Joint Visual-Textual Sentiment Analysis

    为此,提出了一种跨模态回归(Cross-Modality Consistent Regression,CCR)模型。该模型能够结合最新的视觉和文本情感分析技术,利用图像情感分析的卷积神经网络(Convolutional Neural Network,CNN)和文本情感...

    Oracle命中率 笔记整理结合实例

    SQL> SELECT NAME, PHYSICAL_READS, DB_BLOCK_GETS, CONSISTENT_GETS, 1 - (PHYSICAL_READS / (DB_BLOCK_GETS + CONSISTENT_GETS)) "Hit Ratio" FROM V$BUFFER_POOL_STATISTICS WHERE NAME='DEFAULT'; 通常情况下,...

    arraysize对consistent的影响

    在Oracle数据库中,`ARRAYSIZE`是一个非常重要的参数,它直接影响到SQL查询的性能,特别是对`CONSISTENT GETS`这一性能指标有着显著的影响。`CONSISTENT GETS`是指在执行SQL语句时,为了获取一致性读取的数据块(即...

    SQL执行计划简单分析

    SQL 执行计划简单分析 在 SQL 优化中,分析执行计划是一个非常重要的步骤。执行计划可以帮助我们了解 SQL ...递归调用、DB Block Gets 和 Consistent Gets 等统计信息可以帮助我们了解 SQL 语句的执行过程和资源消耗。

    oracle性能调优之buffer cache

    * 查看 Buffer Cache 的命中率,使用公式 1 - (physical reads cache / consistent gets from cache + db block gets from cache)计算。 * 在多 Buffer Pool 情况下,分别统计不同 Buffer Pool 的命中率。 * 查看...

Global site tag (gtag.js) - Google Analytics