sqlserver的日常检查脚本归结
2012-02-15 12:23:49 来源:WEB开发网print '-------------------------------------------------------'
print '16.4找出过多编译/重新编译的 DMV 查询'
print '-------------------------------------------------------'
select * from sys.dm_exec_query_optimizer_info
where
counter = 'optimizations'
or counter = 'elapsed time'
go
print ' '
print ' '
print '-------------------------------------------------------'
print '16.5显示已重新编译的前 25 个存储过程'
print '-------------------------------------------------------'
select top 25
sql_text.text,
sql_handle,
plan_generation_num,
execution_count,
dbid,
objectid
from sys.dm_exec_query_stats a
cross apply sys.dm_exec_sql_text(sql_handle) as sql_text
where plan_generation_num > 1
order by plan_generation_num desc
go
print ' '
print ' '
print '-------------------------------------------------------'
print '16.6哪个查询占用了最多的 CPU 累计使用率'
print '-------------------------------------------------------'
SELECT
ltrim(highest_cpu_queries.plan_handle) as plan_handle,
ltrim(highest_cpu_queries.total_worker_time) as total_worker_time,
q.dbid,
ltrim(q.objectid),
q.number,
q.encrypted,
q.[text]
from
(select top 50
qs.plan_handle,
qs.total_worker_time
from
sys.dm_exec_query_stats qs
order by qs.total_worker_time desc) as highest_cpu_queries
cross apply sys.dm_exec_sql_text(plan_handle) as q
order by highest_cpu_queries.total_worker_time desc
go
print ' '
print ' '
- ››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表' (数...
更多精彩
赞助商链接