sql server 内存_SQL Server内存性能指标–第6部分–其他内存指标

sql server 内存

Memory Manager metrics, the memory pressure can be indicated via the 内存管理器指标,可以通过 Buffer Manager metrics, as the buffer is the component that uses most of the SQL Server memory 缓冲区管理器指标指示内存压力,因为缓冲区是使用大多数SQL Server内存的组件

There is a range of other memory metrics that are not as indicative, and therefore are not commonly used. In this article, we’ll present some of them

其他内存度量标准的范围也不是指示性的,因此并不常用。 在本文中,我们将介绍其中一些

分页文件使用率 (Paging File % Usage)

Paging File % Usage indicates the amount of the paging file used by the operating system

分页文件使用率百分比表示操作系统使用的分页文件的数量

Paging is a process that occurs on systems with insufficient. To provide enough memory for the running processes, it temporarily stores some of the memory pages into the paging file on disk. Next time a process needs this page, it will not be read from RAM, but from the page file on disk

分页是在系统不足的情况下发生的过程。 为了为正在运行的进程提供足够的内存,它将某些内存页面临时存储到磁盘上的页面文件中。 下次进程需要此页面时,将不会从RAM中读取它,而是从磁盘上的页面文件中读取它

When there’s no memory pressure on the system, every process has enough memory, pages are written into memory and flushed after the process is completed, freeing up the page for the forthcoming process

当系统没有内存压力时,每个进程都有足够的内存,页面将被写入内存并在进程完成后刷新,从而为即将到来的进程释放页面

A hard page fault is when the page is not in memory, but has to be loaded from a paging file on disk. This affects performance, as writing and reading a page from disk is several times slower than writing and reading from memory

硬页面错误是指该页面不在内存中,而必须从磁盘上的页面文件中加载。 这会影响性能,因为从磁盘写入和读取页面比从内存写入和读取要慢几倍

A soft page fault is when a page is still in memory, but on another address, or is being used by another program. Soft page faults don’t affect performance

软页面错误是指页面仍在内存中,但在另一个地址上,或正在被另一个程序使用。 软页面错误不会影响性能

A useful information related to the paging file usage is the size of the operating system paging file and how much paging file space is available. You can obtain this information from the dm_os_sys_memory view

与分页文件使用相关的有用信息是操作系统分页文件的大小以及可用的分页文件空间。 您可以从dm_os_sys_memory视图获取此信息。

 
SELECT total_page_file_kb, available_page_file_kb, 
system_memory_state_desc
FROM sys.dm_os_sys_memory 
 

Dialog showing size of the operating system paging file

Frequent paging and using a large percentage of the paging file requires reducing system workload or adding more memory

频繁的分页和使用大量的分页文件需要减少系统工作量或增加内存

The threshold you should not reach depends on the size of the paging file, but shouldn’t be more than 70%. As a rule of thumb, you can set the paging file to be 50% of total RAM

您不应达到的阈值取决于页面文件的大小,但不应超过70%。 根据经验,您可以将页面文件设置为总RAM的50%

“100 percent usage of a page file does not indicate a performance problem as long as the system commit limit is not reached by the system commit charge, and if a significant amount of memory is not waiting to be written to a page file.”[1]

“只要系统提交费用未达到系统提交限制,并且没有大量内存等待写入页面文件,页面文件的100%使用率并不表示性能问题。 ” [1]

Graph showing values and threshold of the Paging File % Usage metric

连接内存(KB) (Connection Memory (KB))

The Connection Memory (KB) metric “specifies the total amount of dynamic memory the server is using for maintaining connections” [2]

连接内存(KB)指标“指定服务器用于维护连接的动态内存总量” [2]

This is the amount of memory used for storing connection context as well as network send and receive buffers

这是用于存储连接上下文以及网络发送和接收缓冲区的内存量

As this is one of the Memory Manager counters, you can obtain its value using a query such as

由于这是内存管理器计数器之一,因此您可以使用查询来获取其值,例如

 
SELECT object_name, counter_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE [counter_name] = 'Connection Memory (KB)'
 

This is where another metric comes in useful – User connections which shows the number of users currently connected to SQL Server

这是另一个有用的度量标准-用户连接,显示当前连接到SQL Server的用户数

 
SELECT object_name, counter_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE [counter_name] = 'User Connections'
 

Dialog showing values of the Connection Memory and User connections

If the number of user connections is much higher than expected, the memory used per connection varies significantly, or these values are constantly increasing, the situation should be investigated and excessive connections killed. Besides being a performance issue, this can be an indication of a security problem

如果用户连接数比预期的高得多,每个连接使用的内存变化很大,或者这些值一直在增加,则应调查这种情况并终止过多的连接。 除了性能问题之外,这还可以指示安全问题。

Graph showing values of the Connection Memory and User connections

检查点页面数/秒 (Checkpoint Pages/sec)

Checkpoint Pages/sec shows the number of pages that are moved from buffer to disk per second during a checkpoint process

Checkpoint页数/秒显示在检查点过程中每秒从缓冲区移动到磁盘的页面数

SQL Server tries to provide enough available space in the buffer in order to provide good performance. To free up the space in the buffer, the modified (dirty) pages are periodically moved (flushed) from the buffer to disk, and the page in the buffer is set for overwriting. This process occurs at checkpoints

SQL Server尝试在缓冲区中提供足够的可用空间以提供良好的性能。 为了释放缓冲区中的空间,已修改的(脏)页面会定期从缓冲区移至磁盘(磁盘),然后将缓冲区中的页面设置为覆盖。 此过程发生在检查点

This number of pages moved at a checkpoint is relative and depends on the hardware configuration and server usage. It’s recommended to create a baseline for this metric and compare the current values to it

在检查点移动的页面数量是相对的,并且取决于硬件配置和服务器使用情况。 建议为该指标创建一个基准并与之比较当前值

If more pages are flushed at each checkpoint, it might indicate an I/O problem. This is where besides automatic checkpoints, indirect checkpoints should be used, as they can be issued automatically to reduce the time between 2 automatic checkpoints and reduce the number of flushed dirty pages per second

如果在每个检查点刷新了更多页面,则可能表明I / O问题。 在这里,除了自动检查点之外,还应该使用间接检查点,因为它们可以自动发出以减少两个自动检查点之间的时间并减少每秒刷新的脏页数

Graph showing values and threshold of the Checkpoint Pages/sec metric

服务器内存被盗(KB) (Stolen Server Memory (KB))

Stolen Server Memory (KB) shows the amount of memory used by SQL Server, but not for database pages. It is used for sorting or hashing operations, or “as a generic memory store for allocations to store internal data structures such as locks, transaction context, and connection information” [3]

被盗服务器内存(KB)显示SQL Server使用的内存量,但不显示数据库页面使用的内存量。 它用于排序或散列操作,或“用作分配用于存储内部数据结构(如锁,事务上下文和连接信息)的通用内存存储” [3]。

The Stolen Server Memory (KB) counter was introduced in SQL Server 2012. In earlier versions, there was the Stolen pages counter

SQL Server 2012中引入了被盗服务器内存(KB)计数器。在早期版本中,存在被盗页面计数器

 
SELECT object_name, counter_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE [counter_name] = 'Stolen Server Memory (KB)'
 

Dialog showing values of the Stolen Server Memory (KB) metric

There’s no specific threshold value, so it’s recommended to monitor this counter for a while and set a baseline. Note that the value should be close to the Batch Requests/sec value and low compared to the Total Server Memory counter. A high amount of stolen memory indicates memory pressure

没有特定的阈值,因此建议监视此计数器一段时间并设置基准。 请注意,该值应接近“批处理请求数/秒”值,并且与“ 总服务器内存”计数器相比较低。 大量的内存被盗表明内存压力

Graph showing values of the Stolen Server Memory and the Total Server Memory

锁块,已分配锁块,锁内存(KB)和锁所有者块 (Lock Blocks, Lock Blocks Allocated, Lock Memory (KB), and Lock Owner Blocks)

A lock block is a locked source, such as a table, page, or row

锁定块是锁定的源,例如表,页面或行

Locking is a normal process on SQL Server. When a process uses a resource (e.g. page), the resource is locked. If another process tries to use the same resource, it will have to wait until the resource is released, which affects performance

锁定是SQL Server上的正常过程。 当进程使用资源(例如页面)时,该资源将被锁定。 如果另一个进程尝试使用相同的资源,则必须等待直到释放该资源,这会影响性能。

Locks occur when a process holds a resource longer than it should before releasing it, e.g. due to inefficient queries, or an error occurs so that the resource is not released automatically

当进程持有资源的时间长于释放资源之前的时间(例如,由于查询效率低下)或发生错误,因此不会自动释放资源时,就会发生锁定

Lock Blocks shows the number of lock blocks in use on the server (refreshed periodically). A lock block represents an individual locked resource, such as a table, page, or row

锁定块显示服务器上正在使用的锁定块的数量(定期刷新)。 锁定块代表单个锁定的资源,例如表,页面或行

Lock Blocks Allocated shows the number of lock blocks allocated to support locks. The more locks occur, the more will be allocated

分配的锁定块显示分配给支持锁定的锁定块的数量。 发生的锁越多,分配的锁就越多

Lock Memory (KB) shows the total amount of memory the server is using for locks

锁定内存(KB)显示服务器用于锁定的内存总量

Lock Owner Blocks shows the number of lock owner blocks currently in use on the server. A lock owner block is a thread that is the owner of a lock

锁拥有者块显示了服务器上当前正在使用的锁拥有者块的数量。 锁所有者块是作为锁所有者的线程

 
SELECT object_name, counter_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE [counter_name] in ('Lock Blocks', 'Lock Blocks Allocated', 'Lock Memory (KB)', 'Lock Owner Blocks')
 

Dialog showing values of the Lock Blocks, Lock Blocks Allocated, Lock Memory (KB), and Lock Owner Blocks counters

When SQL Server is set to use dynamic lock allocation, 2500 lock blocks and 5000 lock owner blocks will be initially allocated per node

当SQL Server设置为使用动态锁分配时,最初将为每个节点分配2500个锁块和5000个锁所有者块

The number of Lock Blocks should be lower than less than 1,000. If the value is higher, query tuning and optimization are the first steps to solve this issue

锁块的数量应少于1,000个。 如果该值较高,则查询调优和优化是解决此问题的第一步

The Lock Memory (KB) value should be lower than 24% of the available memory

锁定内存(KB)值应小于可用内存的24%

Graph showing values of the Lock Blocks and Lock Memory counters

Besides these, the following metrics can help with SQL Server memory performance indication, but are of no great significance: Free Memory (KB), Optimizer Memory (KB), Reserved Server Memory (KB), SQL Cache Memory (KB), Page lookups/sec, and Readahead pages/sec [1]

除此之外,以下指标还可以帮助指示SQL Server内存性能,但意义不大:可用内存(KB),优化器内存(KB),预留服务器内存(KB),SQL高速缓存内存(KB),页面查找/秒和预读页面/秒[1]

翻译自: https://www.sqlshack.com/sql-server-memory-performance-metrics-part-6-memory-metrics/

sql server 内存

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值