我在此查詢上得到一個隨機/間歇性的SQL超時,看起來像從一個簡單的查詢中產生大量的處理。這是正確的行爲?SQL超時地理查詢
我有這樣一個簡單的存儲過程:
CREATE PROCEDURE [dbo].[FindClosestXNearCoordinates]
@latitude decimal,
@longitude decimal
AS
BEGIN
SET NOCOUNT ON;
declare @emptyGUID uniqueidentifier
set @emptyGUID = cast(cast(0 as binary) as uniqueidentifier)
declare @radiusInMeters float
set @radiusInMeters = 3500 * 1609.344
declare @coordinatePoint as Geography
SET @coordinatePoint = geography::STGeomFromText('POINT(' + CAST(@longitude AS VARCHAR(20)) + ' ' + CAST(@latitude AS VARCHAR(20)) + ')', 4326)
declare @coordinateRadius as Geography
set @coordinateRadius = @coordinatePoint.STBuffer(@radiusInMeters);
select top 1 [b].[BaseId], [b].[Code], [b].[Name], [b].[Location], [b].[TerritoryId], [b].[Latitude], [b].[Longitude]
from XTable b
where (b.GeoLocation.STIntersects(@coordinateRadius) = 1)
order by b.GeoLocation.STDistance(@coordinatePoint) asc
END
我捕捉到它在SQL事件探查器,它顯示的查詢和超過188陳述成一排,這是因爲當我在SSMS運行這真的令人困惑它只顯示1個執行,但在應用程序中運行會生成188個子語句。:
[link] http://i.imgur.com/4Bk9y.jpg這裏是配置文件轉儲。 – ExtremeCoder123