首页 > 其他分享 >了解视图dm_os_performance_counters的cntr_type含义

了解视图dm_os_performance_counters的cntr_type含义

时间:2022-09-29 12:04:45浏览次数:50  
标签:dm Ratio name Cache 视图 计数器 cntr Hit type


dm_os_performance_counters说明

该视图用于查看数据库的性能指标,但是不同的指标类型(cntr_type)计算方法有所不同。

大概有以下不同类型:

select object_name,counter_name,instance_name,cntr_value,
case cntr_type
when 65792 then '所见即所得,无需计算'
when 65536 then '所见即所得,无需计算'
when 272696576 then '累计值'
when 1073874176 then '需要除以同名 Base对应的值'
when 537003264 then '需要除以同名 Base对应的值'
end as counter_comments
from sys.dm_os_performance_counters
where cntr_type not in (1073939712);

1、PERF_COUNTER_LARGE_RAWCOUNT:65792:

PERF_COUNTER_LARGE_RAWCOUNT 计数器类型的 cntr_types 列值为 65792。这些计数器显示最后观察到的值,而不是平均值。它通常用于监视对象计数 这意味着,如果计数器类型为 65792,那么在查询视图时在 counter_value 列中得到的值就是该计数器的当前值,不需要额外计算。也就是"所见即所得"。

如:查看Page life expectancy

SELECT *
FROM sys.dm_os_performance_counters
WHERE counter_name = 'Page Life expectancy'
AND object_name LIKE '%buffer manager%';

了解视图dm_os_performance_counters的cntr_type含义_所见即所得

该类型的计数器类型有:*General Statistics User connections, Buffer Manager Page life expectancy and Database pages, Databases – Data and Log file size (KB), Log file used size (KB), Percent Log used, Memory Manager – Free Memory (KB),*等等。

查看SQL:

select distinct object_name,counter_name from sys.dm_os_performance_counters where cntr_type=65792

2、PERF_LARGE_RAW_BASE:1073939712

PERF_LARGE_RAW_BASE 计数器类型的 cntr_types 列值为 1073939712。这些计数器收集最后观察到的值,该计数器值用作进一步计算的​​分母​​。此类型的计数器仅用于计算通过视图可用的其他计数器,属于此计数器类型的所有计数器的名称中都包含单词 base,因此清楚地表明这不是提供有用信息的计数器,它只是进一步计算的基值。

通常用于计算命中率相关信息,如:

SELECT *
FROM sys.dm_os_performance_counters
WHERE counter_name = 'Buffer cache hit ratio base'

了解视图dm_os_performance_counters的cntr_type含义_sed_02

Buffer Cache Hit Ratio % = 100 * Buffer Cache Hit Ratio /Buffer Cache Hit Ratio Base

= 100 * 2,135 / 3,573

= 59.75%

该类型的计数器类型有:Buffer Cache Hit Ratio Base, Log Cache Hit Ratio Base, Average Latch Wait Time Base, Cache Hit Ratio Base, CPU usage % base, and more

查看SQL:

select distinct object_name,counter_name from sys.dm_os_performance_counters where cntr_type=1073939712

3、PERF_AVERAGE_BULK :1073874176

PERF_AVERAGE_BULK 计数器类型的 cntr_types 列值为 1073874176。 cntr_value 列值是累积的。要计算计数器的当前值,必须监视 PERF_AVERAGE_BULK 及其对应的 PERF_LARGE_RAW_BASE 计数器(1073939712),同时取两个样本,并使用这些值进行计算。

如:计算平均等待时间

SELECT *
FROM sys.dm_os_performance_counters
WHERE counter_name LIKE '%Average Wait Time%'
AND instance_name = 'database'

时间点 T1:

了解视图dm_os_performance_counters的cntr_type含义_sed_03

时间点T2:

了解视图dm_os_performance_counters的cntr_type含义_所见即所得_04

即:Average Wait Time (ms) = (53736 ms -52939 ms)/(23-18) = 797 ms / 5 = 159.4 ms

该类型的计数器类型有:*Average Wait Time (ms), Average Latch Wait Time (ms), Update conflict ratio, Avg. Length of Batched Writes, Avg. Time to Write Batch (ms), Avg. Time Between Batches (ms)*等等。

4、PERF_LARGE_RAW_FRACTION :537003264

PERF_LARGE_RAW_FRACTION 计数器类型的 cntr_types 列值为 537003264。这些计数器用来计算命中率,即两个值之间的分数 - PERF_LARGE_RAW_FRACTION 计数器及其对应的 PERF_LARGE_RAW_BASE 计数器值的比值。

如:查看缓存命中率

SELECT *
FROM sys.dm_os_performance_counters
WHERE counter_name like 'Buffer cache hit ratio%'

了解视图dm_os_performance_counters的cntr_type含义_sql_05

Buffer Cache Hit Ratio % = 100 * Buffer Cache Hit Ratio /Buffer Cache Hit Ratio Base = 100* 564/564 = 100.

该类型的计数器类型有:Buffer Cache Hit Ratio, Log Cache Hit Ratio, Worktables From Cache Ratio, Cache Hit Ratio, CPU usage %, and Rem Req Cache Hit Ratio等。

5、PERF_COUNTER_BULK_COUNT:272696576

PERF_COUNTER_BULK_COUNT 计数器类型的 cntr_types 列值为 272696576。这些计数器显示的值是累积的,它是自上次 SQL Server 实例重新启动以来的累积值,因此需要对其实际值进行采样,与 PERF_AVERAGE_BULK 计数器类型相同。

但是,了解采样周期有多长很重要。否则,将无法计算每秒的值。通常使用 5 分钟的时间段,要计算每秒速率,请计算两个样本值之间的差异,然后将其除以样本之间的秒数。

如:计算Page lookups/秒

DECLARE @PageLookups1 BIGINT;

SELECT @PageLookups1 = cntr_value
FROM sys.dm_os_performance_counters
WHERE counter_name = 'Page lookups/sec';

WAITFOR DELAY '00:00:10';

SELECT (cntr_value - @PageLookups1) / 10 AS 'Page lookups/sec'
FROM sys.dm_os_performance_counters
WHERE counter_name = 'Page lookups/sec';

了解视图dm_os_performance_counters的cntr_type含义_所见即所得_06

该类型的计数器类型有:Page lookups/sec, Free list stalls/sec, Lazy writes/sec, Page reads/sec, Page writes/sec, Logins/sec等等。


标签:dm,Ratio,name,Cache,视图,计数器,cntr,Hit,type
From: https://blog.51cto.com/u_12946336/5722436

相关文章

  • Tensorflow savedmodel to graph def
    1.使用tf2onnx工具,把savedmodel转换为tf的graphdef(不带function,也就是tf1的计算图)https://github.com/onnx/tensorflow-onnx/blob/v1.9.3/tf2onnx/tf_loader.py#-*......
  • 我希望拥有的 Typescript 指南 — 阅读错误,第 1 部分
    我希望拥有的Typescript指南—阅读错误,第1部分通过视觉指南和简单的语言学习如何阅读Typescript中的错误Typescript可能充斥着错误和警告,似乎是每一件小事。以......
  • DML语句--删除
    DELETE命令:语法:DELETEfrom表名[where条件]--删除数据(避免这样写,会全部删除)DELETEFROM‘student‘--删除指定数据DELETEFROM‘student‘WHEREid=......
  • DML语言--修改
    修改:语法:  UPDATE表名set colnum_name=valuewhere[条件]--修改多个属性,用逗号隔开update‘student‘SET‘name‘='狂神',‘email‘='[email protected]......
  • DML语言
    DML语言:数据库操作语言插入语句(添加)其实就是在表中填入信息语法:insertinto表名([字段名1,字段名2,字段名3])value('值1','值2','值3',.....)注意事项:字段和字段名之......
  • [Typescript] 40. Medium - IsNever
    ImplementatypeIsNever,whichtakesinputtypeT.Ifthetypeofresolvestonever,returntrue,otherwisefalse.Forexample:typeA=IsNever<never>//ex......
  • [Typescript] Tips: Decode URL search params at the type level with ts-toolbelt
    TypeScript'sstringinterpolationpowersareincredible,especiallysince4.1.Addsomeutilitiesfrom ts-toolbelt,andyou'vegotastewgoing.Here,wedeco......
  • TypeNameExtractor could not be found
    TypeNameExtractorcouldnotbefoundException一、注意:如果项目中使用了knif4j或swagger(knif4j内核中就使用了swagger)项目启动时可能就会出现下边的异常DynamicR......
  • Linux挂载U盘报错:mount: unknown filesystem type 'ntfs'
    问题:Linux挂载U盘时,报错mount:unknownfilesystemtype'ntfs'错误。这是由于Linux上无法识别NTFS格式的分区的原因。解决办法:安装ntfs-3g[root@localhost~]#wgeth......
  • 原型(prototype)、原型链和原型继承
    一、原型 prototype 和 __proto__ 每个对象都有一个__proto__属性,并且指向它的prototype原型对象每个构造函数都有一个prototype原型对象prototype原型对象里的c......