sql库缓存命中率_SQL Server内存性能指标–第4部分–缓冲区高速缓存命中率和页面寿命期望

本文关注SQL Server性能指标中的两个关键缓冲区管理计数器:缓冲区高速缓存命中率和页面寿命期望。缓冲区高速缓存命中率体现了SQL Server从缓冲区读取数据页的效率,理想的值应超过90。页面寿命期望则表示页面在缓冲区中停留的平均时间,正常值应高于300秒。这两个指标对于识别和解决内存压力问题至关重要。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

sql库缓存命中率

In SQL Server performance metrics – part 3, we presented some of the SQL Server Buffer Manager metrics. As the SQL Server buffer pool manages data cache, it’s important to monitor various buffer pool metrics as they help identify and solve memory pressure issues

SQL Server性能指标(第3部分)中 ,我们介绍了一些SQL Server Buffer Manager指标。 由于SQL Server缓冲池管理数据缓存,因此监视各种缓冲池指标非常重要,因为它们有助于识别和解决内存压力问题。

In this article, we will present 2 more Buffer Manager counters – Buffer Cache Hit Ratio and Page Life Expectancy.

在本文中,我们将介绍另外2个Buffer Manager计数器-Buffer Cache Hit RatioPage Life Expectancy

缓冲区高速缓存命中率 (Buffer Cache Hit Ratio)

Buffer Cache Hit Ratio shows how SQL Server utilizes buffer cache

缓冲区高速缓存命中率显示了SQL Server如何利用缓冲区高速缓存

“Percent of page requests satisfied by data pages from the buffer pool” [1]

“缓冲池中的数据页满足的页面请求百分比” [1]

It gives the ratio of the data pages found and read from the SQL Server buffer cache and all data page requests. The pages that are not found in the buffer cache are read from the disk, which is significantly slower and affects performance

它给出了从SQL Server缓冲区缓存中发现和读取的数据页与所有数据页请求的比率。 从磁盘读取缓冲区高速缓存中未找到的页面,这会大大降低速度并影响性能。

Ideally, SQL Server would read all pages from the buffer cache and there will be no need to read any from disk. In this case, the Buffer Cache Hit Ratio value would be 100. The recommended value for Buffer Cache Hit Ratio is over 90. When better performance is needed, the minimal acceptable value is 95. A lower value indicates a memory problem

理想情况下,SQL Server将从缓冲区高速缓存中读取所有页面,并且无需从磁盘读取任何页面。 在这种情况下, 缓冲区高速缓存命中率的值将为100。建议的缓冲区高速缓存命中率的值超过90。当需要更好的性能时,可接受的最小值为95。较低的值表示存在内存问题

The fact that “after a long period of time, the ratio moves very little” [2] explains the biggest disadvantage of this metric. In situations when performance is changing significantly, Buffer Cache Hit Ratio shows little variations, so you cannot be aware of the significance of the change. That’s why other metrics, such as Page Life Expectancy are suggested. Their values can quickly drop or raise, which clearly indicates significant changes that require attention

“经过很长一段时间后,比率几乎没有变化” [2]的事实说明了该指标的最大缺点。 在性能发生显着变化的情况下, 缓冲区高速缓存命中率几乎没有变化,因此您无法意识到更改的重要性。 这就是为什么建议使用其他指标(例如“ 页面寿命预期 ”)的原因。 它们的值可以快速下降或上升,这清楚表明需要注意的重大变化

The same as with other Buffer Manager metrics, it’s value can be obtained from the sys.dm_os_performance_counters view

与其他缓冲区管理器指标相同,可以从sys.dm_os_performance_counters视图获取该值

 
SELECTobject_name, counter_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE [object_name] LIKE '%Buffer Manager%'
AND [counter_name] = 'Buffer cache hit ratio'
 

Buffer Cache Hit Ratio table value

Values and threshold graph for Buffer Cache Hit Ratio

Due to inert behavior of Buffer Cache Hit Ratio, the values it shows can be misleading and it’s recommended to check values of other SQL Server Buffer Manager counters, such as Page Life Expectancy, Free list stalls/sec, Page reads/sec, etc.

由于缓冲区高速缓存命中率的惰性行为,其显示的值可能会产生误导,建议您检查其他SQL Server 缓冲区管理器计数器的值,例如页面寿命期望空闲列表停顿/秒页面读取/秒等。

网页预期寿命 (Page Life Expectancy)

“Duration, in seconds, that a page resides in the buffer pool” [2]

“页面驻留在缓冲池中的持续时间(以秒为单位)” [2]

SQL Server has more chances to find the pages in the buffer pool if they stay there longer. If the page is not in the buffer pool, it will be read from disk, which affects performance. If there’s insufficient memory, data pages are flushed from buffer cache more frequently, to free up the space for the new pages

SQL Server有更多机会在缓冲池中找到页面,如果它们停留的时间更长。 如果该页不在缓冲池中,则会从磁盘读取该页,这会影响性能。 如果内存不足,则会更频繁地从缓冲区高速缓存中刷新数据页,以释放新页的空间。

When there’s sufficient memory on the server, pages have a high life expectancy. The normal values are above 300 seconds (5 minutes) and the trend line should be stable. It’s recommended to monitor the values over time, as frequent quick drops indicate memory issues. Also, a value drop of more than 50% is a sign for deeper investigation

当服务器上有足够的内存时,页面的预期寿命就很高。 正常值高于300秒(5分钟),趋势线应稳定。 建议定期监控这些值,因为频繁的快速删除指示内存问题。 而且,价值下降超过50%表示需要进行更深入的调查

As typical hardware configurations used currently provide more resources, the normal values are often high above 300. If there’s enough memory on the machine, the Page Life Expectancy value will be over 1,000. If the value is below 300, it’s a clear indication that something is wrong

由于当前使用的典型硬件配置可提供更多资源,因此正常值通常会高于300。如果计算机上有足够的内存,则“ 页面预期寿命”值将超过1,000。 如果该值低于300,则表明存在错误

“For example, a server with 230GB RAM allocated to the SQL Server buffer pool and a Page Life Expectancy of 300 would equate roughly to 785MB/sec of I/O activity to maintain the page churn inside of the buffer pool. While it might be possible for the I/O subsystem to keep up with this demand, this represents a significant amount of page churn in the buffer pool” [3]

“例如,为服务器分配230GB RAM到SQL Server缓冲池并且页面预期寿命为300的服务器大约等于785MB / sec的I / O活动,以保持页面在缓冲池中的流失。 尽管I / O子系统可能会满足这种需求,但这表示缓冲池中有大量页面搅动” [3]

 
SELECT object_name, counter_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE [object_name] LIKE '%Buffer Manager%'
AND [counter_name] = 'Page life expectancy'
 

Page Life Expectancy table value

The cause for Page Life Expectancy values below 300 can be poor index design, missing indexes, mismatched data types, insufficient memory, etc.

Page Life Expectancy值低于300的原因可能是索引设计不良,索引丢失,数据类型不匹配,内存不足等。

Values and threshold graph for Page Life Expectancy

翻译自: https://www.sqlshack.com/sql-server-memory-performance-metrics-part-4-buffer-cache-hit-ratio-page-life-expectancy/

sql库缓存命中率

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值