欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

SQL语句实现查询SQL Server内存使用状况

程序员文章站 2023-01-03 15:44:32
select type,--clerk的类型 sum(virtual_memory_reserved_kb)as vm_reserved_kb,--保留的内存...
select type,--clerk的类型  
sum(virtual_memory_reserved_kb)as vm_reserved_kb,--保留的内存  
sum(virtual_memory_committed_kb)as vm_committed_kb,--提交的内存  
sum(awe_allocated_kb)as awe_allocated_kb,--开启awe后使用的内存  
sum(shared_memory_reserved_kb)as sm_reserved_kb,--共享的保留内存  
sum(shared_memory_committed_kb)as sm_committed_kb,--共享的提交内存  
sum(single_pages_kb)as sinlgepage_kb,-- buffer pool中的stolen的内存  
sum(multi_pages_kb)as multipage_kb-- memtoleave的内存
from sys.dm_os_memory_clerks 
group by type order bytype
 
--查询buffer pool/memory to leave
select
 sum(virtual_memory_reserved_kb)as [reserved],
 sum(virtual_memory_committed_kb)as [commit],
 sum(virtual_memory_reserved_kb)/sum(virtual_memory_committed_kb) as[reserved/commit],
 sum(single_pages_kb)+sum(multi_pages_kb) as [stolen],
 sum(virtual_memory_committed_kb)+sum(single_pages_kb)as [buffer pool],
 sum(multi_pages_kb) as[memtoleave],
 sum(awe_allocated_kb)as [aweallocated]
 from sys.dm_os_memory_clerks
 
--查询sqlserver内存使用

select * from sys.dm_os_process_memory