SQL Server数据库解决Performance Dashboard溢出问题是本文我们主要要介绍的内容,接下来我们就开始介绍Performance Dashboard的相关问题及解决措施。注意:在尝试这些解决方案前请备份你的文件,并自负风险。
问题一: 两个datetime列的差别导致了运行时溢出
打开 C:\Program Files\Microsoft SQL Server\90\Tools\PerformanceDashboard\setup.sql.搜索以下代码:
sum(convert(bigint,datediff(ms,login_time,getdate())))–sum(convert(bigint,s.total_elapsed_time))asidle_connection_time,
并用以下代码行替代:
sum(convert(bigint,CAST(DATEDIFF(minute,login_time,getdate())ASBIGINT)*60000+ DATEDIFF(millisecond,DATEADD(minute,DATEDIFF(minute,login_time,getdate()),login_time), getdate())))–sum(convert(bigint,s.total_elapsed_time))asidle_connection_time,
问题二:当Server连续运行超过24天
打开C:\Program Files\Microsoft SQL Server\90\Tools\PerformanceDashboard\recent_cpu.rdl.
删除3271到3306行,并用下面的代码替代它们:
from(selects.session_id, r.request_id, s.login_time, –s.host_name, s.program_name, s.login_name, s.statusassession_status, s.last_request_start_time, s.last_request_end_time, s.cpu_timeassession_cpu_time, r.cpu_timeasrequest_cpu_time, –s.logical_readsassession_logical_reads, –r.logical_readsasrequest_logical_reads, r.start_timeasrequest_start_time, r.statusasrequest_status, r.command, master.dbo.fn_varbintohexstr(r.sql_handle)assql_handle, master.dbo.fn_varbintohexstr(r.plan_handle)asplan_handle, r.statement_start_offset, r.statement_end_offset, case –Steve:Fixesbeginhere: whenconvert(bigint,CAST(DATEDIFF(minute,start_time,getdate())ASBIGINT)*60000+DATEDIFF(millisecond, DATEADD(minute,DATEDIFF(minute,start_time,getdate()),Start_time),getdate())) >0 thenconvert(float,r.cpu_time)/convert(bigint,CAST(DATEDIFF(minute,start_time,getdate())ASBIGINT)*60000 +DATEDIFF(millisecond,DATEADD(minute,DATEDIFF(minute,start_time,getdate()),Start_time),getdate()))elseconvert(float,1.0)end asavg_request_cpu_per_ms, isnull(datediff(ms,casewhenr.start_time<@WithActivitySincethen@WithActivitySinceelser.start_timeend,getdate()),0) asrequest_ms_in_window, casewhens.login_time>getdate()thenconvert(float,s.cpu_time)/(datediff(dd,s.login_time,getdate())*cast(86400000asbigint)+datediff(ms,dateadd(dd,datediff(dd,s.login_time,getdate()),s.login_time),getdate()))elseconvert(float,1.0) endasavg_session_cpu_per_ms, convert(bigint,isnull(datediff(s,casewhens.login_time<@WithActivitySincethen@WithActivitySinceelses.login_timeend,casewhenr.request_idisnullthens.last_request_end_timeelsegetdate()end),0))*1000 assession_ms_in_window fromsys.dm_exec_sessionss leftjoinsys.dm_exec_requestsasrons.session_id=r.session_idands.session_id=1–Steve:Fixesendhere where(s.last_request_end_time>@WithActivitySinceorr.request_idisnotnull))asd where(avg_request_cpu_per_ms*request_ms_in_window)+(avg_session_cpu_per_ms*session_ms_in_window)>1000.0</CommandText><QueryParameters><QueryParameterName=”@WithActivitySince”><Value>=Parameters!WithActivitySince.Value</Value></QueryParameter></QueryParameters><DataSourceName>DataSource1</DataSourceName></Query>
问题三:转换表达式的数据类型时出现算术溢出
这个问题大多出现在点击蓝色CPU区域。打开 C:\Program Files\Microsoft SQL Server\90\Tools\PerformanceDashboard\recent_cpu.rdl.
搜索WithActivitySince参数,并将它从String换成Datetime.
关于SQL Server数据库解决Performance Dashboard溢出问题的相关知识就介绍到这里了,希望本次的介绍能够对您有所收获!
【编辑推荐】
- SQL Server数据库托管代码的使用详解从物理结构上谈一谈SQL Server数据库的优化SQL Server 2008 R2命名故障转移群集的实例解析SQL Server使用UNION代替OR提升查询性能的实例SQL Server数据库中FOR XML AUTO的使用详解续