I'm searching for the nearest ten neighboring points from a given point.
When I use this query:
SELECT id, geom, ST_Distance(geography(geom), ST_GeographyFromText('SRID=4326;POINT(-0.22707 51.5444204)')) as distance
FROM cars
ORDER BY geom <-> 'SRID=4326;POINT(-0.22707 51.5444204)'::geometry
LIMIT 10;
I don't get the same result as when I use this query:
SELECT id, geom, ST_Distance(geography(geom), ST_GeographyFromText('POINT(-0.22707 51.5444204)')) as distance
FROM cars
ORDER BY distance
LIMIT 10;
Three of the 10 points returned are different. And when viewing it in QGIS it looks like the best result is the last query. I need to use index-based KNN because of performance issues.
Does anyone have any ideas?