SQL Server数据库解决Performance Dashboard溢出问题

数据库 SQL Server
本文我们主要介绍了在使用SMSS Performance Dashboard时由于两个datetime列的差别导致了运行时Performance Dashboard溢出的问题分析及相应的解决措施,希望能够对您有所帮助。

SQL Server数据库解决Performance Dashboard溢出问题是本文我们主要要介绍的内容,接下来我们就开始介绍Performance Dashboard的相关问题及解决措施。注意:在尝试这些解决方案前请备份你的文件,并自负风险。

问题一: 两个datetime列的差别导致了运行时溢出

打开 C:\Program Files\Microsoft SQL Server\90\Tools\PerformanceDashboard\setup.sql.搜索以下代码:

 

  1. sum(convert(bigint, datediff(ms, login_time, getdate()))) – sum(convert(bigint, s.total_elapsed_time)) as idle_connection_time, 

 

并用以下代码行替代:

 

  1. sum(convert(bigint, CAST ( DATEDIFF ( minute, login_time, getdate()) AS BIGINT)*60000 +   
  2. DATEDIFF ( millisecond, DATEADD ( minute, DATEDIFF ( minute, login_time, getdate() ), login_time ),  
  3. getdate() ))) – sum(convert(bigint, s.total_elapsed_time)) as idle_connection_time, 

 

问题二:当Server连续运行超过24天

打开C:\Program Files\Microsoft SQL Server\90\Tools\PerformanceDashboard\recent_cpu.rdl.

删除3271到3306行,并用下面的代码替代它们:

 

  1. from (select s.session_id,  
  2. r.request_id,  
  3. s.login_time,  
  4. – s.host_name,  
  5. s.program_name,  
  6. s.login_name,  
  7. s.status as session_status,  
  8. s.last_request_start_time,  
  9. s.last_request_end_time,  
  10. s.cpu_time as session_cpu_time,  
  11. r.cpu_time as request_cpu_time,  
  12. – s.logical_reads as session_logical_reads,  
  13. – r.logical_reads as request_logical_reads,  
  14. r.start_time as request_start_time,  
  15. r.status as request_status,  
  16. r.command,  
  17. master.dbo.fn_varbintohexstr(r.sql_handle) as sql_handle,  
  18. master.dbo.fn_varbintohexstr(r.plan_handle) as plan_handle,  
  19. r.statement_start_offset,  
  20. r.statement_end_offset,  
  21. case   
  22. – Steve: Fixes begin here:  
  23. when convert(bigint, CAST ( DATEDIFF ( minute, start_time, getdate()) AS BIGINT)*60000 + DATEDIFF ( millisecond,   
  24. DATEADD ( minute,DATEDIFF ( minute, start_time, getdate() ), Start_time ),getdate() ))   
  25. > 0   
  26. then convert(float, r.cpu_time) / convert(bigint, CAST ( DATEDIFF ( minute, start_time, getdate()) AS BIGINT)*60000   
  27. + DATEDIFF ( millisecond, DATEADD ( minute, DATEDIFF ( minute, start_time, getdate() ), Start_time ),getdate() )) else convert(float, 1.0) end  
  28. as avg_request_cpu_per_ms,  
  29. isnull (datediff(ms, case when r.start_time < @WithActivitySince then @WithActivitySince else r.start_time end, getdate()), 0)   
  30. as request_ms_in_window,  
  31. 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)   
  32. end as avg_session_cpu_per_ms,  
  33. 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  
  34. as session_ms_in_window  
  35. from sys.dm_exec_sessions s  
  36. left join sys.dm_exec_requests as r on s.session_id = r.session_id and s.session_id = 1 
  37. – Steve: Fixes end here  
  38. where (s.last_request_end_time > @WithActivitySince or r.request_id is not null)) as d  
  39. where (avg_request_cpu_per_ms * request_ms_in_window) + (avg_session_cpu_per_ms * session_ms_in_window) &gt; 1000.0</CommandText> 
  40. <QueryParameters> 
  41. <QueryParameter Name=”@WithActivitySince”> 
  42. <Value>=Parameters!WithActivitySince.Value</Value> 
  43. </QueryParameter> 
  44. </QueryParameters> 
  45. <DataSourceName>DataSource1</DataSourceName> 
  46. </Query> 

 

问题三:转换表达式的数据类型时出现算术溢出

这个问题大多出现在点击蓝色CPU区域。打开 C:\Program Files\Microsoft SQL Server\90\Tools\PerformanceDashboard\recent_cpu.rdl.

搜索WithActivitySince参数,并将它从String换成Datetime.

关于SQL Server数据库解决Performance Dashboard溢出问题的相关知识就介绍到这里了,希望本次的介绍能够对您有所收获!

【编辑推荐】

  1. SQL Server数据库托管代码的使用详解
  2. 从物理结构上谈一谈SQL Server数据库的优化
  3. SQL Server 2008 R2命名故障转移群集的实例解析
  4. SQL Server使用UNION代替OR提升查询性能的实例
  5. SQL Server数据库中FOR XML AUTO的使用详解续

 

责任编辑:赵鹏 来源: 博客园
相关推荐

2010-07-06 14:40:15

解决SQL Serve

2010-07-15 17:28:50

SQL Server

2018-05-15 08:44:44

TensorFlowKeras内存

2011-07-07 09:40:05

SQL Server虚拟化数据库

2009-05-04 13:43:16

SQL Server置疑数据库恢复

2010-06-18 09:31:51

SQL Server数

2011-08-23 09:45:34

SQL Server多表关联汇总查询

2021-03-06 10:25:19

内存Java代码

2010-07-08 11:05:14

SQL Server数

2011-03-14 13:18:41

SQL Server数权限

2010-07-05 14:41:21

SQL Server数

2011-01-19 09:51:25

SQL Server

2011-04-06 16:15:21

SQL Server数简体繁体

2021-05-17 06:57:34

SQLServer数据库

2021-02-03 15:12:08

java内存溢出

2010-10-20 17:21:07

连接SQL Serve

2011-04-29 14:30:23

2011-04-01 17:05:44

SQL Server数日志

2010-06-30 11:16:50

SQL Server

2009-03-19 09:44:07

SQL Server数据库迁移数据库
点赞
收藏

51CTO技术栈公众号