Sql Server 性能分析3 –数据库大小,数据库表大小综合性分析
2009-09-05 00:00:00 来源:WEB开发网/* 当前的数据库大小与昨天的数据库大小做比较得来*/
Create Procedure [dbo].[Proc_DBA_Database_Size_Grow]
as
select date_time,
database_name,
db_size,
size_type
from TB_DBA_Database_Size
where database_name = 'InsiteProdDG'
and convert(varchar(10),date_time,120)=convert(varchar(10),getdate(),120)
union all
(select date_time,
database_name,
db_size*-1,
size_type
from TB_DBA_Database_Size
where database_name = 'InsiteProdDG'
and convert(varchar(10),date_time,120)=convert(varchar(10),dateadd(day,-1,getdate()),120)
)
------获取数据库表增长大小----
/* 当前的数据库表大小与昨天的数据库表大小做比较得来*/
Create Procedure [dbo].[Proc_DBA_MES_Table_Grow]
as
select convert(varchar(20),getdate(),120) as date_time,
name,
sum(rows) as rows,
sum(reserved) as reserved,
sum(data) as data,
sum(index_size) as index_size,
sum(unused) as unused,
'KB' as Size_Type
from
(select * from
(select top 10
name,
cast(rows as int) as rows,
cast(left(reserved,len(reserved)-2) as int) as reserved,
cast(left(data,len(data)-2)as int) as data,
cast(left(index_size,len(index_size)-2) as int) as index_size,
cast(left(unused,len(unused)-2) as int) as unused
from TB_DBA_Database_Table_Size
where convert(varchar(10),date_time,120)=convert(varchar(10),getdate(),120)
order by cast(rows as int) desc) t
union
select
name,
rows*-1 as rows,
left(reserved,len(reserved)-2) *-1 as reserved,
left(data,len(data)-2) *-1 as data,
left(index_size,len(index_size)-2) *-1 as index_size,
left(unused,len(unused)-2) *-1 as unused
from TB_DBA_Database_Table_Size
where convert(varchar(10),date_time,120)=convert(varchar(10),dateadd(day,-1,getdate()),120)
and name in(
select top 10 name
from TB_DBA_Database_Table_Size
where convert(varchar(10),date_time,120)=convert(varchar(10),getdate(),120)
order by cast(rows as int) desc)
) x
group by name
order by 3 desc
- ››sql server自动生成批量执行SQL脚本的批处理
- ››sql server 2008亿万数据性能优化
- ››SQL Server 2008清空数据库日志方法
- ››sqlserver安装和简单的使用
- ››SQL Sever 2008 R2 数据库管理
- ››SQL SERVER无法安装成功,sqlstp.log文件提示[未发...
- ››Sql Server中通过父记录查找出所有关联的子记录
- ››SqlServer触发器、存储过程和函数
- ››SQL Server 中的事务(含义,属性,管理)
- ››Sqlite数据库插入和读取图片数据
- ››Sql server 2005拒绝了对对象 'xx表' (数...
- ››Sql server 2005拒绝了对对象 'xx表' (数...
更多精彩
赞助商链接