查看: 5338|回复: 9

请问在视图v$sysstat中,"db block gets"和"consistent gets"到

[复制链接]
论坛徽章:
7
操作系统板块每日发贴之星
日期:2005-06-20 01:01:48操作系统板块每日发贴之星
日期:2005-06-26 01:01:51数据库板块每日发贴之星
日期:2005-08-19 01:01:25会员2006贡献徽章
日期:2006-04-17 13:46:342011新春纪念徽章
日期:2011-02-18 11:42:48ITPUB十周年纪念徽章
日期:2011-11-01 16:20:282012新春纪念徽章
日期:2012-01-04 11:50:44
跳转到指定楼层
1#
发表于 2005-12-20 18:11 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
请问在视图v$sysstat中,"physical reads"、
"db blockgets"和"consistent gets"到底是指什么?
书上如下:
physical reads:从磁盘存取的数据块的总数(phy)
db block gets:因更新而获得的缓冲区总数(cur)
consistent gets:在一致读取中获得的缓冲区总数(con)
命中率:round((1-(phy.value/(cur.value+con.value)))*100,1)
请问我如下的理解对不对:
1、"physical reads"是不是指这个数据块在缓冲区中没有,要从数据文件中重新读这个数据块。
2、"db blockgets"指这个数据块在缓冲区中有但和数据文件中的内容不一样,这就得从数据文件中重新读这个数据块。
3、"consistent gets"指这个数据块在缓冲区中有且和数据文件中的内容一样,直接从缓冲区中读。
如果我的理解对的话我认为命中率应为:
round((1-(phy.value+cur.value)/(phy.value+cur.value+con.value))*100,1)
即1-物理读取/(物理读取+缓冲区读取)
请大家多多指教,怎么也看不明白。
论坛徽章:
7
操作系统板块每日发贴之星
日期:2005-06-20 01:01:48操作系统板块每日发贴之星
日期:2005-06-26 01:01:51数据库板块每日发贴之星
日期:2005-08-19 01:01:25会员2006贡献徽章
日期:2006-04-17 13:46:342011新春纪念徽章
日期:2011-02-18 11:42:48ITPUB十周年纪念徽章
日期:2011-11-01 16:20:282012新春纪念徽章
日期:2012-01-04 11:50:44
2#
 楼主| 发表于 2005-12-21 07:25 | 只看该作者
大家来帮帮忙呀!

使用道具 举报

回复
论坛徽章:
62
2015中国数据库技术大会纪念徽章
日期:2015-04-24 16:04:24版主2段
日期:2012-05-15 15:24:112012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-01-04 11:49:54ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41现任管理团队成员
日期:2011-05-07 01:45:08
3#
发表于 2005-12-21 08:58 | 只看该作者
db blockgets  包括physical reads

使用道具 举报

回复
论坛徽章:
3
数据库板块每日发贴之星
日期:2006-02-18 01:02:33会员2007贡献徽章
日期:2007-09-26 18:42:10ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44
4#
发表于 2005-12-21 10:45 | 只看该作者
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))

使用道具 举报

回复
论坛徽章:
30
ITPUB元老
日期:2005-02-28 12:57:00ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41管理团队成员
日期:2011-05-07 01:45:082010数据库技术大会纪念徽章
日期:2010-05-13 09:34:23数据库板块每日发贴之星
日期:2006-06-21 01:01:30数据库板块每日发贴之星
日期:2006-06-12 01:01:37会员2006贡献徽章
日期:2006-04-17 13:46:34数据库板块每日发贴之星
日期:2005-12-03 01:01:33授权会员
日期:2005-10-30 17:05:33ITPUB社区OCM联盟徽章
日期:2014-04-01 13:07:37
5#
发表于 2005-12-21 10:57 | 只看该作者
Statistic:      DB BLOCK GETS
Layer:          Cache
Identifier:     kcbycu                    Registered In:  kcb.h

Definition:     "db block gets" counts logical reads in current mode.
                Also includes direct read blocks (sort-on-disk) blocks.

Statistic:      CONSISTENT GETS
Layer:          Cache
Identifier:     kcbycr                    Registered In:  kcb.h

Definition:     "consistent gets" counts the logical read in consistent mode.

Statistic:      PHYSICAL READS
Layer:          Cache
Identifier:     kcbypr                    Registered In:  kcb.h

Definition:     This statistic stores the number of BLOCKS read from the
                operating system disk subsystem. Each block read from disk
                is a buffer cache miss.  

                Note that it is *NOT* the number of IO requests made to the
                disk subsystem. If it was then full table scans would
                not be represented properly by <Statistic:Cache_Hit_Ratio>.

使用道具 举报

回复
论坛徽章:
7
操作系统板块每日发贴之星
日期:2005-06-20 01:01:48操作系统板块每日发贴之星
日期:2005-06-26 01:01:51数据库板块每日发贴之星
日期:2005-08-19 01:01:25会员2006贡献徽章
日期:2006-04-17 13:46:342011新春纪念徽章
日期:2011-02-18 11:42:48ITPUB十周年纪念徽章
日期:2011-11-01 16:20:282012新春纪念徽章
日期:2012-01-04 11:50:44
6#
 楼主| 发表于 2005-12-24 14:07 | 只看该作者
SQL> r
  1  select * from v$sysstat
  2  where name='physical reads'
  3  or name='db block gets'
  4* or name ='consistent gets'

STATISTIC# NAME            CLASS      VALUE
---------- ---------- ---------- -            ---------
        40 db block gets          8           28194
        41 consistent gets         8          63018
        42 physical reads          8           2728

SQL>
dba_mx:如你所说consistent gets是物理读,那么应是physical reads>consistent gets,但上面不是这样呀?

使用道具 举报

回复
论坛徽章:
7
操作系统板块每日发贴之星
日期:2005-06-20 01:01:48操作系统板块每日发贴之星
日期:2005-06-26 01:01:51数据库板块每日发贴之星
日期:2005-08-19 01:01:25会员2006贡献徽章
日期:2006-04-17 13:46:342011新春纪念徽章
日期:2011-02-18 11:42:48ITPUB十周年纪念徽章
日期:2011-11-01 16:20:282012新春纪念徽章
日期:2012-01-04 11:50:44
7#
 楼主| 发表于 2005-12-24 14:12 | 只看该作者
Definition: "consistent gets" counts the logical read in consistent mode.
中这个consistent mode是什么意思?
我是这样理解的:consistent gets是指这个数据块在再次读取时通过SCN确定它没有改变,所以直接从buffer cache中读取!
Definition: "db block gets" counts logical reads in current mode.
Also includes direct read blocks (sort-on-disk) blocks.
又是什么意思?

使用道具 举报

回复
论坛徽章:
7
操作系统板块每日发贴之星
日期:2005-06-20 01:01:48操作系统板块每日发贴之星
日期:2005-06-26 01:01:51数据库板块每日发贴之星
日期:2005-08-19 01:01:25会员2006贡献徽章
日期:2006-04-17 13:46:342011新春纪念徽章
日期:2011-02-18 11:42:48ITPUB十周年纪念徽章
日期:2011-11-01 16:20:282012新春纪念徽章
日期:2012-01-04 11:50:44
8#
 楼主| 发表于 2005-12-24 16:15 | 只看该作者
明白了,总结如下,大家看对不对
(1)buffer_gets=db block gets + consistent gets = LOGIC IO(逻辑读次数)
(2)consistent get : 在一致读模式下所读的快数,包括从回滚段读的快数。
  db block gets : 在当前读模式下所读的快数,比较少和特殊,例如数据字典数据获取,在DML中,更改或删除数据是要用到当前读模式。
(3)db block gets : current mode , 不管这个块上的数据是否可能存在 before image ,也就是说不管是否存在回滚中数据可以 回滚,只看见当前最新块的数据,即使别人正在更新,也看见别人更新状态的数据,比如dml的时候就不需要看见别人更改前的数据,而是看见正在更改的,当然同时,若操作相同数据则被lock住。也就是说一次查询中看见的数据可能不在同一个时间点上,比如一个大的dml,当dml 开始更新一个非常大的表后,这个表更新的过程中,有一个进程去把该表末尾的一个记录更新了,然后这个大更新抵达该记录的时候会被阻塞的,若该进程事物提交,则大更新会覆盖该事务的更新,也就是说,这个大更新所看见的数据是当前的,不具有时间点的一致性,所以叫 current mode,个人认为db block gets这个词用的不好, 容易让人误解. 如果改成inconsistent gets可能会更准确一些

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

使用道具 举报

回复
论坛徽章:
3
数据库板块每日发贴之星
日期:2006-02-18 01:02:33会员2007贡献徽章
日期:2007-09-26 18:42:10ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44
9#
发表于 2005-12-24 17:32 | 只看该作者
引自(biti_rainy):

把问题简单并粗略化:
db block gets 看作是 DML 的读取 ,其看到的数据可能不具有时间点的一致性。
consistent gets 是 select 这样的读取,无论是否来自回滚段的数据都是 consistents gets ,仅仅表示其看到的数据具有时间点上的一致性。

使用道具 举报

回复
论坛徽章:
52
摩羯座
日期:2015-07-23 16:30:53马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11问答徽章
日期:2014-01-14 17:25:10兰博基尼
日期:2013-12-16 09:09:38大众
日期:2013-12-11 15:24:03林肯
日期:2013-12-04 12:21:38保时捷
日期:2013-11-22 15:45:33雪佛兰
日期:2013-09-12 12:10:44奥迪
日期:2013-08-22 17:17:49
10#
发表于 2005-12-24 21:53 | 只看该作者
学习,明白了当前模式和db block gets。

使用道具 举报

回复

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

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表