查询花费了太多时间来执行 [英] Query is taking too much time to execute

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

问题描述

SELECT * FROM ( 
	SELECT 
		TrackerResponse.EventName, 
		TrackerResponse.ReceiveTime, 
		ISNULL(TrackerResponse.InputStatus, 0) AS InputStatus, 
		TrackerResponse.Latitude, 
		TrackerResponse.Longitude, 
		TrackerResponse.Temperature, 
		TrackerResponse.Speed, 
        TrackerResponse.TrackerID, 
		TrackerResponse.OdoMeter, 
		TrackerResponse.Direction, 
		UserCar.CarNo,
		ROW_NUMBER() OVER (PARTITION BY UserCar.CarNo ORDER BY ReceiveTime DESC) AS row 
	FROM TrackerResponse
		INNER JOIN UserCar ON (UserCar.TrackerID = TrackerResponse.TrackerID)
    WHERE 
		TrackerResponse.EventName IS NOT NULL AND 
		TrackerResponse.EventName <> '' AND 
		TrackerResponse.TrackerID in (34,46,56,45,55,52,58,47,53,48,50,68,70,72,73,74,75,76,78,79,80,81,82,83,84,85,97,98,87,99,100,101,102,103,104,105,106,86,88,54,108,109,110,114,111,113,112,115,117,118) 
) a 
WHERE 
	row >= 0 and row <= 20



此查询执行时间过长。大部分时间都是时间过期了。


This query is taking too much time to execute. Most of the time it is time-expired.

推荐答案

从细节上我们不可能说如何改善执行时间......

SQL执行查询所需的时间取决于很多很多因素...

1.实际数据大小(主要是行数,也是行的大小)

2.索引(和键和FKeys)

3.索引和键和FKeys使用的数据类型

4.还有更多。 ..



你应该谷歌并开始阅读这个主题...

查询性能调优(SQL Server Compact) [ ^ ]

第14章 - 提高SQL Server性能 [ ^ ]
It is impossible to say from the details we have how to improve the execution time...
The time it takes to the SQL execute a query depends on many, many factors...
1. Actual size of data (number of rows mainly but also the size of rows too)
2. Indexes (and keys and FKeys)
3. Types of data used for indexes and keys and FKeys
4. Some more...

You should Google and start reading on the subject...
Query Performance Tuning (SQL Server Compact)[^]
Chapter 14 - Improving SQL Server Performance[^]


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

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