Why is this Postgis distance query so slow? Postgres' query estimator off by a factor of 10000x?
问题 I'm trying to find all posts that were within a certain distance, but unfortunately for some inputs the query is extremely slow. Here's some examples: -- fast (1 millisecond) SELECT 1 FROM post po WHERE ST_DWithin(po.geog, ST_SetSRID(ST_MakePoint(-47, -70), 4326)::geography, 4500 * 1609.34) LIMIT 10; -- slow (2 seconds) SELECT 1 FROM post po WHERE (po.geog <-> ST_SetSRID(ST_MakePoint(-47, -70), 4326)::geography) < 4500 * 1609.34 LIMIT 10; -- slow (9 seconds) SELECT 1 FROM post po WHERE ST