493: Undecipherable

-Blog-

-Projects-

-About me-

-RSS-

SQLServer STContains() performance

Dennis Guse

For some reason SQLServer 2017 is picky with regard to performance for geography comparisons.

The first statement seems is rather slow (seems to ignore spatial indeces) while the second one works impressively fast on my data.

SELECT *
FROM MyGeodata
WHERE MyGeoData.SHAPE.STContains(MyGeoData.POINT) <> 0
SELECT *
FROM MyGeodata
WHERE MyGeoData.SHAPE.STContains(MyGeoData.POINT) = 1

NOTE: I would prefer the first variant as technically NOT(False) is TRUE and TRUE is everything except 0.