set statistics io,time on; 查詢語句消耗時間
2.設置內存大小
--開啓數據庫高級選項
exec sp_configure 'show advanced options',1
go
reconfigure with override
go
exec sp_configure 'max server memory (MB)',80000
go
reconfigure with override
go
3.sp_block 'r' 正在執行進程 sp_block 所有進程,包括緩存
4.
看錶的行數
看錶的索引
sp_helpindex 表名
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
exec sp_configure 'xp_cmdshell',1
go
reconfigure with override
go
7.查詢庫使用情況
SELECT a.name as 邏輯文件名, size/128 [文件大小(兆)],
FILEPROPERTY(a.name, 'SpaceUsed')/128 [已用空間(兆)],
size/128 - FILEPROPERTY(a.name, 'SpaceUsed')/128 [未用空間(兆)],
FILEPROPERTY(a.name, 'SpaceUsed')*100.0/size [使用率(%)],
case when max_size=-1 then N'無限制' else convert(char(20),max_size/128) end [最大值(兆)]
, case when growth>100 then convert(varchar(20),growth/128) else CONVERT(varchar(20),growth)+'%'end 增長值MB,
case when is_percent_growth=0 then N'否'else N'是'end 是否百分比增長, physical_name 物理路徑,b.*
FROM sys.database_files a cross join (select recovery_model_desc, log_reuse_wait,log_reuse_wait_desc,is_auto_shrink_on from sys.databases where name=DB_NAME())b