I'm trying to test the performance of spatial indexes on Latitude/Longitude values in a table of 1.7 million postcodes. I've created a geography column and added an index to it, however the query using the spatial index is dramatically (at least 100x) slower than the one using the 'normal' index on the Lat/Long columns in the same table, yet the query plan shows the index is being used.
Here is my query:
DECLARE @point GEOGRAPHY
SET @point = geography::STGeomFromText('POINT(-1.31548 51.06390)', 4326)
SELECT postcode , location.STDistance(@point) AS dist
FROM dbo.Postcodes WITH(INDEX(IX_Postcodes_SpatialIndex))
WHERE location.STIntersects(@point.STBuffer(200)) = 1
ORDER BY location.STDistance(@point)
How can I go about debugging what's happening here?
EDIT: I accepted most of the defaults when creating the index:
CREATE SPATIAL INDEX [IX_Postcodes_SpatialIndex] ON [dbo].[Postcodes] (Location)
USING GEOGRAPHY_AUTO_GRID
ON [PRIMARY]
Query plan: (you may need to zoom in ;)