查询sqlserver表占用空间,查询当前数据库缓存的所有数据页面,查询当前数据库经常访问的表

查询某张表的磁盘占用情况:

sql 复制代码
--第一种
EXEC sp_spaceused '表_测试表';



--第二种
SELECT 
    OBJECT_NAME(object_id) AS TableName,
    SUM(used_page_count) * 8 AS UsedSpaceKB
FROM 
    sys.dm_db_partition_stats
GROUP BY 
    object_id;

查询当前数据库缓存的所有数据页面,哪些数据表,缓存的数据页面数量 -- 从这些信息可以看出,系统经常要访问的都是哪些表,有多大?

sql 复制代码
select p.object_id, object_name=object_name(p.object_id), p.index_id, buffer_pages=count(*) from
 sys.allocation_units a, sys.dm_os_buffer_descriptors b, 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() group by p.object_id,p.index_id order by buffer_pages desc
相关推荐
xuefuhe3 天前
SQL Server 监控login的IP
sqlserver
半桶水专家3 天前
SQL Server DML 操作语句完全指南
数据库·sqlserver
测试修炼手册14 天前
[测试技术] JUnit 6 入门与实战:断言、参数化与 Mockito
数据库·junit·sqlserver
心之语歌14 天前
SQL Server 按月分区实战:动态边界自动生成方案
sqlserver
bosins18 天前
部署SSIS并增加SQL Server代理作业,任务正常执行但事件查看器一直报DCOM权限问题
sqlserver·ssis·权限·dcom·事件查看器
xuefuhe18 天前
SQL Server sp_replmonitorsubscriptionpendingcmds
sqlserver
龙仔72521 天前
SQL Server 批量多库只读账号一键脚本(带逐行注释完整脚本 + 分段逐句详细解释)
服务器·数据库·sql·sqlserver·dba
xuefuhe1 个月前
SQL Server查看系统存储过程及视图的定义
sqlserver
techdashen1 个月前
Uber 如何完成超大规模 JUnit 迁移:从 JUnit 4 到 JUnit 5 的自动化工程实践
junit·sqlserver·自动化
xuefuhe1 个月前
SQL Server Configuration Manager报Cannot connect to WMI provider错误
sqlserver