1

I 간단한 쿼리에서 많은 처리를 생성하는 것처럼이 쿼리에서 임의/간헐적 인 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 프로파일 러를 캡처하고 그 쿼리와 내가 SSMS에서이 프로그램을 실행할 때 때문에 정말 혼란 행, 188여 문을 보여줍니다 단지 하나의 실행을 보여 주지만 응용 프로그램에서 실행하면 188 개의 하위 문장이 생성됩니다. :

+0

[link] http://i.imgur.com/4Bk9y.jpg 여기 프로필 덤프가 있습니다. – ExtremeCoder123

답변

0

먼저 SQL 프로파일 러. Spatial 유형은 SQL 서버에 다소 특수하므로 처리가 추가로 필요합니다. 동일한 TSQL 문에 대해 SP : Starting 및 SP : Completed 항목을 여러 번 등록합니다. 이는 TSQL 수준에서만 작업을보고 할 수 있기 때문입니다. 당신은 단지 이것으로 살아야 할 것입니다. 그것은 SQL 서버에서 동일 쿼리 시간 제한과 관련하여 2012 년

, 내가하고자하는 조건을 좀 더 기초적인 테스트로 STIntersect()를 교체하고 제안

where (b.longitude between @[email protected] and @[email protected]) 
    and (b.latitude between @[email protected] and @[email protected]) 
order by b.GeoLocation.STDistance(@coordinatePoint) asc 

그리고 키를 파악하는 것 미터를 십진수 값으로 변환하여 적절한 @xdelta. 전환이 순간적으로 나를 피할 수는 있지만 Google은 당신의 친구입니다. 필요하다면 STIntersect (버퍼)를 추가 할 수도 있습니다.

+0

감사합니다. 나는 그것이 2012 년에 테스트하지 않은 지리라고 생각하고 업데이트 할 것입니다. – ExtremeCoder123