dbcc extentinfo 查看磁盘分区 分析压缩数据库对象

DBCC EXTENTINFO命令用于查询某个数据库、或者某个数据对象(主要是数据表)的盘区分配情况,然后计算每个对象理论上

区的数目和实际数目,如果实际数目远大于理论的数目,那这个对象就是碎片过多,管理员应该要考虑重建对象

 

建立下面的存储过程帮助分析:


create table extentinfo 
[file_id] smallint
page_id 
int
pg_alloc 
int
ext_size 
int
obj_id 
int
index_id 
int
partition_number 
int,
partition_id 
bigint,
iam_chain_type 
varchar(50),
pfs_bytes 
varbinary(10) ) 
go 
drop proc import_extentinfo
go
create procedure import_extentinfo 
as dbcc extentinfo('test_shrink'
go 
insert extentinfo  
exec import_extentinfo 
go 

select * from extentinfo 
select [file_id],obj_id, index_id, partition_id, ext_size, 
'actual extent count'=count(*), 'actual page count'=sum(pg_alloc), 
'possible extent count'=ceiling(sum(pg_alloc)*1.0/ext_size), --一个对象的所有盘区页数的各/
'possible extents / actual extents' = (ceiling(sum(pg_alloc)*1.00/ext_size)*100.00/ count(*
from extentinfo 
group by [file_id],obj_id, index_id,partition_id, ext_size 
having count(*)-ceiling(sum(pg_alloc)*1.0/ext_size) > 0 
order by partition_id, obj_id, index_id, [file_id]


盘区信息的含义

字段名称

说    明

file_id

数据库的数据文件编号

page_id

在某个盘区中的第一个页面的页面号

 

pg_alloc

该盘区为数据库分配的页面数量m(1≤m≤8)

ext_size

盘区的大小,以页面为单位

object_id

数据库对象的ID

index_id

表示数据对象的类型

partition_number

分区号

rows

大约的数据行数

hobt_id

存储数据的堆或B树的存储单元ID



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值