查询某张表的磁盘占用情况:
--第一种
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;
查询当前数据库缓存的所有数据页面,哪些数据表,缓存的数据页面数量 – 从这些信息可以看出,系统经常要访问的都是哪些表,有多大?
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
发表评论