故障诊断和性能优化.配合Profiler,dashboard一起使用很不错

WBOY
Release: 2016-06-07 15:10:01
Original
1209 people have browsed it

优化 SQL Server 2005 的动态管理视图DMV和函数DMF SQL Server 05提供了动态管理视图Dynamic Management Views和函数 Functions,方便了我们对系统运行情况的监控, 故障 诊断 和 性能 优化 . 配合 Profiler,dashboard 一起 使用 很 不错 . 1. 使用 sys.dm_exe

优化SQL Server 2005 的动态管理视图DMV和函数DMF
SQL Server 05提供了动态管理视图Dynamic Management Views和函数 Functions,方便了我们对系统运行情况的监控, 故障 诊断性能 优化. 配合Profiler,dashboard 一起 使用不错.
1. 使用sys.dm_exec_query_stats和sys.dm_exec_sql_text找到CPU占用率高的语句
SELECT TOP 100 execution_count,
total_logical_reads /execution_count AS [Avg Logical Reads],
total_elapsed_time /execution_count AS [Avg Elapsed Time],
db_name(st.dbid) as [database name],
object_name(st.dbid) as [object name],
object_name(st.objectid) as [object name 1],
SUBSTRING(st.text, (qs.statement_start_offset / 2) + 1,
((CASE statement_end_offset WHEN - 1 THEN DATALENGTH(st.text) ELSE qs.statement_end_offset END - qs.statement_start_offset)
/ 2) + 1) AS statement_text
FROM sys.dm_exec_query_stats AS qs CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS st
WHERE execution_count > 100
ORDER BY 1 DESC;
--关于statement_start_offset/2的。更多内容http://www.cnblogs.com/ewialitwind/
IO跟踪

setstatistics io on
go
selecttop1*from sales.customer where customertype 'S';
CustomerID TerritoryID AccountNumber CustomerType rowguid ModifiedDate
CustomerID TerritoryID AccountNumber CustomerType rowguid ModifiedDate
----------- ----------- ------------- ------------ ------------------------------------ -----------------------
11000 9 AW00011000 I 477586B3-2977-4E54-B1A8-569AB2C7C4D4 2004-10-13 11:15:07.263
(1 行受影响)
表 'Customer'。扫描计数 1,逻辑读取 6 次,物理读取 0 次,预读 0 次,lob 逻辑读取 0 次,lob 物理读取 0 次,lob 预读 0 次。
--如果需要清理缓存池 DBCC DROPCLEANBUFFER

CPU时间

declare@xint;
declare@cpu_startint;
set@x=1;
set@cpu_start=@@cpu_busy;
set@x=@x+1;
print'ms of cput for loop1:'
+cast ( (@@cpu_busy-@cpu_start) +@@timeticks/1000aschar);
--注意这两个参数 @@cpu_busy @@timeticks.健康知识胆系结石的治疗
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!