SQL Query执行时间太长 [英] SQL Query execute too long time

查看:299
本文介绍了SQL Query执行时间太长的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的SQL Server中有一个包含大约200K记录的数据库表。当我想从表中选择记录来做一个简单的报告时,我需要大约4到5分钟才能完成查询。我收到一条错误消息:



I having a database table with around 200K records in my SQL Server. When I want to select the records from table to do a simple report but it takes me around 4 to 5 minutes to execute finish the query. And I receive an error message :

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.





但是,相同的查询执行速度非常快我自己的电脑,但在另一台电脑上很慢。



SQL查询如下:





However, the same query is execute very fast in my own computer but is slow in another computer.

The SQL query is as below:

Select Region as Regions, count(vehicleplatenumber) As [Total of Region]
From VehicleTransactionLog
Where IsDeleted = 0
AND (DateTimeIn >= '2013-02-01' AND DateTimeIn <= '2013-09-14')
Group by Region





那么,为什么查询在其他计算机上执行得如此之慢以及如何解决这个问题。



感谢高级。



So, why the query is execute so slow in other computer and how to solve this problem.

Thanks in advanced.

推荐答案

如果没有网络问题,请尝试为 DateTimeIn 字段创建索引,看看性能是否有所提升
If there are no Network issues then try creating an Index for DateTimeIn field and see if the performance improves




它们是影响查询性能的几个因素

类似

1)处理器,

2)RAM

3)执行计划



我想在这里说你可以尝试在SQL服务器管理工​​作室运行查询并检查查询计划是否仍然花时间然后尝试在DateTimeIn列上创建索引。



如果仍存在问题,请检查SQL Server DMV命令以获取详细信息。

HTTP:// indiandotnet.wordpress.com/2010/06/17/how-to-determine-which-index-will-be-helpful-in-sql-server-database-table/ [ ^ ]


这篇关于SQL Query执行时间太长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆