SQL Server數(shù)據(jù)庫解決Performance Dashboard溢出問題
SQL Server數(shù)據(jù)庫解決Performance Dashboard溢出問題是本文我們主要要介紹的內(nèi)容,接下來我們就開始介紹Performance Dashboard的相關(guān)問題及解決措施。注意:在嘗試這些解決方案前請備份你的文件,并自負風(fēng)險。
問題一: 兩個datetime列的差別導(dǎo)致了運行時溢出
打開 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)) as idle_connection_time,
并用以下代碼行替代:
- sum(convert(bigint, CAST ( DATEDIFF ( minute, login_time, getdate()) AS BIGINT)*60000 +
- DATEDIFF ( millisecond, DATEADD ( minute, DATEDIFF ( minute, login_time, getdate() ), login_time ),
- getdate() ))) – sum(convert(bigint, s.total_elapsed_time)) as idle_connection_time,
問題二:當Server連續(xù)運行超過24天
打開C:\Program Files\Microsoft SQL Server\90\Tools\PerformanceDashboard\recent_cpu.rdl.
刪除3271到3306行,并用下面的代碼替代它們:
- from (select s.session_id,
- r.request_id,
- s.login_time,
- – s.host_name,
- s.program_name,
- s.login_name,
- s.status as session_status,
- s.last_request_start_time,
- s.last_request_end_time,
- s.cpu_time as session_cpu_time,
- r.cpu_time as request_cpu_time,
- – s.logical_reads as session_logical_reads,
- – r.logical_reads as request_logical_reads,
- r.start_time as request_start_time,
- r.status as request_status,
- r.command,
- master.dbo.fn_varbintohexstr(r.sql_handle) as sql_handle,
- master.dbo.fn_varbintohexstr(r.plan_handle) as plan_handle,
- r.statement_start_offset,
- r.statement_end_offset,
- case
- – Steve: Fixes begin here:
- when convert(bigint, CAST ( DATEDIFF ( minute, start_time, getdate()) AS BIGINT)*60000 + DATEDIFF ( millisecond,
- DATEADD ( minute,DATEDIFF ( minute, start_time, getdate() ), Start_time ),getdate() ))
- > 0
- then convert(float, r.cpu_time) / convert(bigint, CAST ( DATEDIFF ( minute, start_time, getdate()) AS BIGINT)*60000
- + DATEDIFF ( millisecond, DATEADD ( minute, DATEDIFF ( minute, start_time, getdate() ), Start_time ),getdate() )) else convert(float, 1.0) end
- as avg_request_cpu_per_ms,
- isnull (datediff(ms, case when r.start_time < @WithActivitySince then @WithActivitySince else r.start_time end, getdate()), 0)
- as request_ms_in_window,
- case when s.login_time > getdate() then convert(float, s.cpu_time) / (datediff(dd, s.login_time, getdate()) * cast(86400000 as bigint) + datediff(ms, dateadd(dd, datediff(dd, s.login_time, getdate()), s.login_time), getdate())) else convert(float, 1.0)
- end as avg_session_cpu_per_ms,
- convert(bigint,isnull(datediff(s, case when s.login_time < @WithActivitySince then @WithActivitySince else s.login_time end, case when r.request_id is null then s.last_request_end_time else getdate() end), 0) )* 1000
- as session_ms_in_window
- from sys.dm_exec_sessions s
- left join sys.dm_exec_requests as r on s.session_id = r.session_id and s.session_id = 1
- – Steve: Fixes end here
- where (s.last_request_end_time > @WithActivitySince or r.request_id is not null)) as d
- where (avg_request_cpu_per_ms * request_ms_in_window) + (avg_session_cpu_per_ms * session_ms_in_window) > 1000.0</CommandText>
- <QueryParameters>
- <QueryParameter Name=”@WithActivitySince”>
- <Value>=Parameters!WithActivitySince.Value</Value>
- </QueryParameter>
- </QueryParameters>
- <DataSourceName>DataSource1</DataSourceName>
- </Query>
問題三:轉(zhuǎn)換表達式的數(shù)據(jù)類型時出現(xiàn)算術(shù)溢出
這個問題大多出現(xiàn)在點擊藍色CPU區(qū)域。打開 C:\Program Files\Microsoft SQL Server\90\Tools\PerformanceDashboard\recent_cpu.rdl.
搜索WithActivitySince參數(shù),并將它從String換成Datetime.
關(guān)于SQL Server數(shù)據(jù)庫解決Performance Dashboard溢出問題的相關(guān)知識就介紹到這里了,希望本次的介紹能夠?qū)δ兴斋@!
【編輯推薦】
- SQL Server數(shù)據(jù)庫托管代碼的使用詳解
- 從物理結(jié)構(gòu)上談一談SQL Server數(shù)據(jù)庫的優(yōu)化
- SQL Server 2008 R2命名故障轉(zhuǎn)移群集的實例解析
- SQL Server使用UNION代替OR提升查詢性能的實例
- SQL Server數(shù)據(jù)庫中FOR XML AUTO的使用詳解續(xù)






