Based on initial EXPLAIN investigations, looks like the distance query is not and actually can not be optimized using PostGIS when the geometry field is in SRID 4326 (i.e. WGS84).
If there was a geometry field that was in a local planar projection that already had its units in meters, then one could use ST_Distance, naturally.
However it's impossible to choose a local planar projection that would fit all use cases and locations, I think...
Based on initial EXPLAIN investigations, looks like the distance query is not and actually can not be optimized using PostGIS when the geometry field is in SRID 4326 (i.e. WGS84).
If there was a geometry field that was in a local planar projection that already had its units in meters, then one could use
ST_Distance
, naturally.However it's impossible to choose a local planar projection that would fit all use cases and locations, I think...