【问题标题】:Query for Buffer Cache Hit Ratio查询缓冲区缓存命中率
【发布时间】:2018-01-20 06:41:13
【问题描述】:

我想计算缓冲区缓存命中率并按实例分组。为此,我有以下公式;

1 - ( physical reads cache / (consistent gets from cache + db block gets from cache)

我需要计算如下公式的查询;

select inst_id,name,value 
from gv$sysstat 
where name in ('consistent gets from cache','db block gets from cache','physical reads cache')

我尝试使用 3 个子查询来实现它,但它没有用且无法正常工作。

此查询的示例输出如下所示;

1   db block gets from cache    3980038
1   consistent gets from cache  16692788
1   physical reads cache        174385

我想要的示例输出如下所示;

INST_ID   VALUE
1         0.92   
2         0.93

如何编写此查询以获得缓存命中率?

【问题讨论】:

  • 您确实意识到 Buffer Cache Hit Ratio(缓冲区高速缓存命中率)即使不是真正不可信的指标,也基本上是无用的指标,不是吗? Find out more
  • @APC 不明白
  • 阅读我链接到的文章。 BHCR 不会告诉您有关数据库状态的任何有意义的信息。
  • APC想说什么:看缓冲区缓存命中率没用。
  • @johntrue - 我正在给你最好的建议:你是否接受它取决于你。

标签: sql oracle


【解决方案1】:

您可以将其用作 RAC 数据库的 Buffer Cache Hit Radio 查询:

select s1.inst_id, s3.value / (s1.value + s2.value) value
  from gv$sysstat s1, gv$sysstat s2, gv$sysstat s3
 where s1.name = 'consistent gets from cache'
   and s2.name = 'db block gets from cache'
   and s3.name = 'physical reads cache'
   and s1.inst_id = s2.inst_id
   and s1.inst_id = s3.inst_id
 order by s1.inst_id;

或者使用 ANSI SQL,可以使用以下查询:

select s1.inst_id, s3.value / (s1.value + s2.value) value
  from gv$sysstat s1 join gv$sysstat s2 on ( s1.inst_id = s2.inst_id ) 
                     join gv$sysstat s3 on ( s1.inst_id = s3.inst_id )
 where s1.name = 'consistent gets from cache'
   and s2.name = 'db block gets from cache'
   and s3.name = 'physical reads cache'
 order by s1.inst_id;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-07
    • 1970-01-01
    • 2012-04-28
    • 2010-11-16
    • 1970-01-01
    • 2011-03-12
    相关资源
    最近更新 更多