SQL查询需要很长时间才能呈现/返回数据

时间:2014-02-07 03:30:04

标签: sql-server sql-server-2008 sql-server-2008-r2

我有两台运行相同SQL查询的服务器。查询在一台服务器上正常运行,但在其他服务器上运行时间太长(37秒)。

我打开了统计数据,我得到了这些结果:

服务器1(此工作正常,结果在2秒内返回):

SQL Server parse and compile time: 
   CPU time = 193 ms, elapsed time = 193 ms.

 SQL Server Execution Times:
   CPU time = 0 ms,  elapsed time = 0 ms.

 SQL Server Execution Times:
   CPU time = 0 ms,  elapsed time = 0 ms.

 SQL Server Execution Times:
   CPU time = 0 ms,  elapsed time = 0 ms.

 SQL Server Execution Times:
   CPU time = 0 ms,  elapsed time = 0 ms.
Jan 30 2014 10:24PM

 SQL Server Execution Times:
   CPU time = 0 ms,  elapsed time = 0 ms.
Feb  6 2014 10:24PM

 SQL Server Execution Times:
   CPU time = 0 ms,  elapsed time = 0 ms.

(6 row(s) affected)

 SQL Server Execution Times:
   CPU time = 172 ms,  elapsed time = 182 ms.

服务器2 :(这需要37秒)

 SQL Server Execution Times:
   CPU time = 0 ms,  elapsed time = 0 ms.

 SQL Server Execution Times:
   CPU time = 0 ms,  elapsed time = 0 ms.

 SQL Server Execution Times:
   CPU time = 0 ms,  elapsed time = 0 ms.
Jan 30 2014 10:24PM

 SQL Server Execution Times:
   CPU time = 0 ms,  elapsed time = 0 ms.
Feb  6 2014 10:24PM

 SQL Server Execution Times:
   CPU time = 0 ms,  elapsed time = 0 ms.

(6 row(s) affected)

 SQL Server Execution Times:
   CPU time = 34255 ms,  elapsed time = 34087 ms.

正如您所看到的那样,问题是渲染查询,出于某些原因,当我从SSRS报告中调用查询时,它会做同样的事情。该报告立即在服务器1上呈现,但在服务器2上永远呈现。

有人可以指出我的方向是正确的吗?

1 个答案:

答案 0 :(得分:1)

请根据您的两台服务器仔细检查并观察这些点,并相互检查:

  1. 配置数据库实例
  2. 查询数据库/表格的设置
  3. 整体流程绩效
  4. 系统内存(当发生延迟时,是否使用HDD扩展RAM?)
  5. 硬盘设置/状态(缓慢/缺陷/碎片硬盘也可能导致此类问题)
  6. 尝试命令“ALTER DATABASE SET PARAMETERIZATION FORCED GO”
  7. 使用DBCC MEMORYSTATUS进行深入分析
  8. 我可能的深度分析的首​​选文档用作概述: http://sqlserverplanet.com/troubleshooting/sql-server-slowness

    您还可以在这里查看: How to analyze 'dbcc memorystatus' result in SQL Server 2008

    否则,你可以在mssqltips dot com上搜索有关如何识别sql server memory / cpu瓶颈的信息(因为我不允许发布更多链接)。他们也有很好的文件。

    希望这会对你有所帮助。