zoukankan      html  css  js  c++  java
  • SQL SERVER-查看内存使用情况

    --使用内存的各对象
    SELECT
        type,
        sum(virtual_memory_reserved_kb) as VM_Reserved,
        sum(virtual_memory_committed_kb) as VM_Committed,
        sum(awe_allocated_kb)  as AWE_Allocated,
        sum(shared_memory_reserved_kb) as SM_Reserved,
        sum(shared_memory_committed_kb) as SM_Committed
    
    from  sys.dm_os_memory_clerks
    group by type
    order by type 
    --查看buffer pool中的各表所占内存
    declare @name  nvarchar(100)
    declare @cmd  nvarchar(1000)
    
    declare dbnames cursor for
    select name from master.dbo.sysdatabases  where  name='SDS_NONEDI_20190627'
    open dbnames
    fetch next from dbnames into  @name
    
    while @@FETCH_STATUS=0
    begin
    
    print(@name)
    
    set @cmd='select b.database_id,db=db_name(b.database_id),p.object_id,p.index_id,buffer_count=count(*) 
    from '+@name+'.sys.allocation_units a,'+@name+'.sys.dm_os_buffer_descriptors b,'+@name+'.sys.partitions p 
    where a.allocation_unit_id=b.allocation_unit_id
    and a.container_id=p.hobt_id
    and b.database_id=db_id('''+@name+''')
    group by b.database_id,p.object_id,p.index_id
    order by b.database_id,buffer_count desc'
    
    print(@cmd)
    exec(@cmd)
    fetch next from dbnames into @name
    end
    close dbnames
    deallocate dbnames 
    go

    查询具体的表格或索引

    SELECT OBJECT_NAME(309576141)
    
    
    SELECT * FROM sys.partitions where object_id=309576141
    
    SELECT * FROM SYS.indexes WHERE object_id=309576141
  • 相关阅读:
    基于XMPP的即时通信系统的建立 — XMPP IQ详解
    XMPPManager 解析
    Xcode 工程文件“.xcodeproj”文件夹解析
    Description &&debugDescription && runtime(debug模式下调试model)
    day04作业
    数字、字符串、列表、字典,jieba库,wordcloud词云
    if,for,异常,random模块,计算圆周率
    day03
    day02
    计算机基础
  • 原文地址:https://www.cnblogs.com/JinweiChang/p/11867865.html
Copyright © 2011-2022 走看看