sp_sysmon
显示性能信息。
语法
sp_sysmon {'begin_sample' | {{'end_sample' | '<interval>'}[, section]}}
[, <applmon>=
{'appl_only' | 'appl_and_login' | 'no_appl' | 'noclear' | 'clear'}
[, <filter>={<cache_wizard_filter_value> | 'noclear' | 'clear'}
[, <dumpcounters>={'y' | 'n' | 'noclear' | 'clear' | NULL}
[, <option>={'noclear' | 'clear' | NULL}]]]]
参数
begin_sample
开始采样。如果指定了 begin_sample,则不能指定部分。
end_sample
结束采样并打印报告。
<interval>
指定采样的时间范围。必须采用 HH:MM:SS 格式,例如“00:20:00”。
`
-
appmgmt – 应用程序管理
-
cache wizard – 高速缓存向导
-
dcache – 数据高速缓存管理
-
diskio – 磁盘 I/O 管理
-
esp – ESP 管理
-
housekeeper – 管家任务活动
-
ndexmgmt – 索引管理
-
kernel – 内核利用率
-
locks – 锁管理
-
memory – 内存管理
-
mdcache – 元数据高速缓存管理
-
monaccess – 对执行 SQL 的监控访问
-
netio – 网络 I/O 管理
-
parallel – 并行查询管理
-
pcache – 过程高速缓存管理
-
recovery – 恢复管理
-
repagent – RepAgent
-
nvcache – NV 高速缓存
-
taskmgmt – 任务管理
-
xactmgmt – 事务管理
-
xactsum – 事务配置文件
-
wpm – 工作进程管理
您还可以使用 sp_monitorconfig 获取 sp_sysmon mdcache 报告中提供的大多数信息。
<applmon>
指定是打印应用程序详细信息、应用程序和登录名详细信息,还是不打印应用程序详细信息。缺省设置为省略应用程序详细信息。有效值及其报告的信息为:
-
appl_only – 按应用程序名称输出的 CPU、I/O、优先级更改和资源限制违反信息。
-
appl_and_login – 按应用程序名和登录名输出的 CPU、I/O、优先级更改和资源限制违反信息。
-
no_appl – 跳过报告的“按应用程序”或“按登录名”部分。这是缺省设置。
只有在打印完整报告并且为 <section> 指定了 appmgmt 时此参数才有效。
noclear | clear
指定是否清除监控计数器:
-
clear – 显式清除监控计数器。
-
noclear – sp_sysmon 不清除监控计数器。noclear 参数的首要作用是提供向后兼容性(sp_sysmon 的早期版本在缺省情况下会清除监控计数器)。
注意仅当在 sp_sysmon 中指定了采样间隔时,才能使用 noclear 参数。如果指定了 begin_sample 或 end_sample,则不能使用 noclear。
缺省情况下,sp_sysmon 不清除用作报告源数据的监控计数器。如果清除计数器时有其它应用程序或 sp_sysmon 报告的实例正在运行,则清除计数器可能会导致它们报告的数据无效。
<filter>
是一种 varchar 数据类型,用来为报告中包括的高速缓存指定模式。
例如,如果将它指定为缺省数据高速缓存,报告将只包含有关缺省数据高速缓存的信息。如果将它指定为 emp%,输出将包括名称与此模式匹配的所有高速缓存的有关信息。如果未指定任何值,输出将包含所有高速缓存,且首先显示缺省数据高速缓存,然后按字母顺序显示其它高速缓存。
'cache wizard'
可帮助监控和配置数据高速缓存以获得最佳性能。
<dumpcounters>
在返回请求的报告部分之后,将 master..sysmonitors 表的内容(包含所有监控计数器的名称和值)作为一个结果集返回。
<option>
如果您已使用所有其它 sp_sysmon 参数指定替代的 sp_sysmon 行为,则允许您指定 clear 或 noclear 参数。有效值为 clear 和 noclear。
示例
监控器信息
在 10 分钟后输出监控信息:
sp_sysmon "00:10:00"
磁盘管理
在 5 分钟后只打印 sp_sysmon 报告的“磁盘管理”部分:
sp_sysmon "00:05:00", diskio
数据高速缓存
开始采样,执行过程和查询,结束采样,然后只打印报告的“数据高速缓存”部分:
sp_sysmon begin_sample
go
execute proc1
go
execute proc2
go
select sum(total_sales) from titles
go
sp_sysmon end_sample, dcache
go
完整报告
打印完整报告,并且包括各个登录名的应用程序和登录名详细信息:
sp_sysmon "00:05:00", @applmon = appl_and_login
不清除计数器
不清除计数器的报告用法:
sp_sysmon "00:01:00", kernel, noclear
也可以使用:
sp_sysmon "00:01:00", noclear
高速缓存向导
使用高速缓存向导打印报告:
sp_sysmon '00:00:30', 'cache wizard'
=============================================================================
Cache Wizard
=============================================================================
------------------
default data cache
------------------Run Size : 100.00 Mb Usage% : 2.86
LR/sec : 41.10 PR/sec : 22.57 Hit%: 45.09
Cache Partitions: 4 Spinlock Contention%: 0.00
Buffer Pool Information
-----------------------------------------------------------------------------
IO Size Wash Size Run Size APF% LR/sec PR/sec Hit% APF-Eff% Usage%
------- ---------- ----------- ------ -------- -------- ------ -------- ------
4 Kb 3276 Kb 16.00 Mb 10.00 0.47 0.13 71.43 n/a 0.20
2 Kb 17200 Kb 84.00 Mb 10.00 40.63 22.43 44.79 n/a 3.37
(1 row affected)
Object Statistics
-----------------------------------------------------------------------------
Object LR/sec PR/sec Hit% Obj_Cached% Cache_Occp%
------------------------------- ------- ------- ------ ----------- -----------
empdb.dbo.t1 0.57 0.30 47.06 56.25 0.02
empdb.dbo.t2 0.30 0.30 0.00 56.25 0.02
empdb.dbo.t3 0.30 0.30 0.00 56.25 0.02
empdb.dbo.t4 0.30 0.30 0.00 56.25 0.02
empdb.dbo.t5 0.30 0.30 0.00 56.25 0.02
empdb.dbo.t6 0.30 0.30 0.00 56.25 0.02
empdb.dbo.t8 0.30 0.30 0.00 56.25 0.02
empdb.dbo.t7 0.57 0.20 64.71 62.50 0.02
tempdb.dbo.tempcachedobjstats 3.63 0.00 100.00 50.00 0.01
tempdb.dbo.tempobjstats 0.47 0.00 100.00 25.00 0.00
Object Obj Size Size in Cache
------------------------------- ----------- -------------
empdb.dbo.t1 32 Kb 18 Kb
empdb.dbo.t2 32 Kb 18 Kb
empdb.dbo.t3 32 Kb 18 Kb
empdb.dbo.t4 32 Kb 18 Kb
empdb.dbo.t5 32 Kb 18 Kb
empdb.dbo.t6 32 Kb 18 Kb
empdb.dbo.t8 32 Kb 18 Kb
empdb.dbo.t7 32 Kb 20 Kb
tempdb.dbo.tempcachedobjstats 16 Kb 8 Kb
tempdb.dbo.tempobjstats 16 Kb 4 Kb
---------
company_cache
---------
Run Size : 1.00 Mb Usage% : 0.39
LR/sec : 0.07 PR/sec : 0.07 Hit%: 0.00
Cache Partitions: 1 Spinlock Contention%: 0.00
Buffer Pool Information
-----------------------------------------------------------------------------
IO Size Wash Size Run Size APF% LR/sec PR/sec Hit% APF-Eff% Usage%
------- ---------- ----------- ------ -------- -------- ------ -------- ------
2 Kb 204 Kb 1.00 Mb 10.00 0.07 0.07 0.00 n/a 0.39
Object Statistics
-----------------------------------------------------------------------------
Object LR/sec PR/sec Hit% Obj_Cached% Cache_Occp%
-------------------- ------- ------- ------ ----------- -----------
empdb.dbo.history 0.07 0.07 0.00 25.00 0.39
Object Obj Size Size in Cache
-------------------- ----------- -------------
empdb.dbo.history 16 Kb 4 Kb
-------------
companydb_cache
-------------
Run Size : 5.00 Mb Usage% : 100.00
LR/sec : 380.97 PR/sec : 56.67 Hit%: 85.13
Cache Partitions: 1 Spinlock Contention%: 0.00
Buffer Pool Information
-----------------------------------------------------------------------------
IO Size Wash Size Run Size APF% LR/sec PR/sec Hit% APF-Eff% Usage%
------- ---------- ----------- ------ -------- -------- ------ -------- ------
2 Kb 1024 Kb 5.00 Mb 10.00 380.97 56.67 85.13 98.42 100.00
Object Statistics
-----------------------------------------------------------------------------
Object LR/sec PR/sec Hit% Obj_Cached% Cache_Occp%
----------------------------- ------- ------- ------ ----------- -----------
company_db.dbo.emp_projects 41.07 22.80 44.48 19.64 9.45
company_db.dbo.dept_det 93.03 20.67 77.79 99.08 54.53
company_db.dbo.emp_perf 116.70 2.63 97.74 97.77 34.18
company_db.dbo.dept_locs 0.43 0.17 61.54 50.00 0.16
Object Obj Size Size in Cache
----------------------------- ----------- -------------
company_db.dbo.emp_projects 2464 Kb 484 Kb
company_db.dbo.dept_det 2818 Kb 2792 Kb
company_db.dbo.emp_perf 1790 Kb 1750 Kb
company_db.dbo.dept_locs 16 Kb 8 Kb
TUNING RECOMMENDATIONS
--------------------------------------------------------------------
Usage% for 'default data cache' is low (< 5%)
Usage% for 4k buffer pool in cache:default data cache is low (< 5%)
Usage% for 2k buffer pool in cache:default data cache is low (< 5%)
Usage% for 'company_cache' is low (< 5%)
Usage% for 2k buffer pool in cache:company_cache is low (< 5%)
Consider adding a large I/O pool for 'companydb_cache'
NV 高速缓存
20 秒后仅打印 sp_sysmon 报告的非易变高速缓存部分:
sp_sysmon "00:00:20", 'nvcache'
===============================================================================
NV Cache Management
---------------------
Cache Statistics Summary (All NV Caches)
----------------------------------------
per sec per xact count % of total
------------ ------------ ---------- ----------
Cache Search Summary
Total Cache Hits 96.9 226.1 2035 46.7 %
Total Cache Misses 110.7 258.2 2324 53.3 %
------------------------- ------------ ------------ ----------
Total Cache Searches 207.6 484.3 4359
Cache Turnover
Buffers Grabbed 110.1 257.0 2313 n/a
Buffers Grabbed Dirty 0.0 0.0 0 0.0 %
-------------------------------------------------------------------------------
Cache: nvcache
per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------
Spinlock Contention n/a n/a n/a 0.0 %
Utilization n/a n/a n/a 100.0 %
Cache Searches
Cache Hits 96.9 226.1 2035 46.7 %
Cache Misses 110.7 258.2 2324 53.3 %
------------------------- ------------ ------------ ----------
Total Cache Searches 207.6 484.3 4359
Cache Turnover
Buffers Grabbed 207.6 484.3 4359 n/a
Buffers Grabbed Dirty 0.0 0.0 0 0.0 %
Cache Device Reads
Cache Device Writes
- Consider increase size for this cache.
- Consider making NV cache lazy cleaner less aggressive.
- Or consider ratio of sizes of NV cache and
main memory caches associated with it
-------------------------------------------------------------------------------
Cache: nvcache2
per sec per xact count % of total
------------------------- ------------ ------------ ---------- ----------
Spinlock Contention n/a n/a n/a 0.0 %
Utilization n/a n/a n/a 0.0 %
Cache Searches
Total Cache Searches 0.0 0.0 0 n/a
------------------------- ------------ ------------ ----------
Total Cache Searches 0.0 0.0 0
Cache Turnover
Buffers Grabbed 0.0 0.0 0 n/a
Cache Device Reads
Cache Device Writes
- Consider making NV cache lazy cleaner more aggressive.
- Or consider ratio of sizes of NV cache and
main memory caches associated with it
- Consider making NV cache lazy cleaner less aggressive.
- Or consider ratio of sizes of NV cache and
main memory caches associated with it
(return status = 0)
用法
使用 sp_sysmon 时,还存在一些其它注意事项:
-
sp_sysmon 显示与 SAP ASE 服务器性能有关的信息。它将内部计数器设置为 0,然后等待指定的时间间隔,与此同时,服务器上的活动将导致计数器增大。间隔结束后,sp_sysmon 将根据计数器中的值打印信息。
-
要只打印报告的某一部分,可使用
sp_sysmon <applmon>的有效值。 -
如果以批处理模式使用 sp_sysmon(使用 begin_sample 和 end_sample),执行之间的时间间隔必须至少为一秒。可以使用
waitfor delay "00:00:01"来延长批处理的执行时间。 -
在采样间隔期间,结果以带符号的整数值存储。特别是在具有多个 CPU 且活动较频繁的系统上,这些计数器可能会溢出。如果 sp_sysmon 输出的结果中有负数,请缩短采样时间。