查询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
相关推荐
简单的话*2 天前
如何查看SQL Server的当前端口
数据库·sqlserver
杰哥技术分享3 天前
Centos-mssql-server安装
linux·sqlserver·centos
一勺-_-6 天前
全栈:JDBC驱动版本和SQLserver版本是否有关系?怎么选择JDBC的版本号?
数据库·sqlserver
水根LP496 天前
利用微软SQL Server数据库管理员(SA)口令为空的攻击活动猖獗
数据库·microsoft·sqlserver·dba
iknow1817 天前
【Web安全】Sql注入之SqlServer和MySQL的区别
sql·mysql·sqlserver
安卓开发者12 天前
Android JUnit 测试框架详解:从基础到高级实践
android·junit·sqlserver
我来整一篇14 天前
[mssql] 分析SQL Server中执行效率较低的SQL语句
数据库·sql·sqlserver
不太厉害的程序员20 天前
Excel 将数据导入到SQLServer数据库
数据库·sqlserver·excel
-曾牛1 个月前
在Windows Server 2012 R2中安装与配置IIS服务并部署mssql靶机教程
运维·服务器·windows·网络安全·sqlserver·渗透测试·渗透测试靶机
猿月亮1 个月前
SQL Server(2022)安装教程及使用_sqlserver下载安装图文
数据库·sqlserver