I need help to improve query performance of a spatial query.
I have the following query:
DECLARE @Longitude float,@Latitude float
SET @Longitude = -79.46278668733325
SET @Latitude = 43.70410072435495
SELECT
GeoLocationBoundary.MakeValid().STCentroid().STDistance(
geometry::STPointFromText(
'POINT(' + CAST(@Longitude AS VARCHAR(20)) + ' ' + CAST(@Latitude AS VARCHAR(20)) + ')', 4326
)
) as DistanceFromCentroid,
*
FROM App.GeoFence
WHERE GeoLocationBoundary.MakeValid().STIntersects(
geometry::STPointFromText(
'POINT(' + CAST(@Longitude AS VARCHAR(20)) + ' ' + CAST(@Latitude AS VARCHAR(20)) + ')', 4326
)
) = 1
What Index should I create as the one I created does not seems to be used when running the query.
Asked by Shawn du Plessis
(19 rep)
Jun 19, 2024, 02:42 PM
Last activity: Jun 19, 2024, 10:25 PM
Last activity: Jun 19, 2024, 10:25 PM