[postgis-devel] ST_DWithin Performance

Zhihong Zhang zhihong at gmail.com
Sat Jan 6 07:14:29 PST 2018

ST_DWithin is implemented like this,

CREATE OR REPLACE FUNCTION ST_DWithin(geom1 geometry, geom2 geometry, float8 RETURNS boolean
AS 'SELECT $1 OPERATOR(@extschema at .&&) @extschema at .ST_Expand($2,$3) AND $2 OPERATOR(@extschema at .&&) @extschema at .ST_Expand($1,$3) AND @extschema at ._ST_DWithin($1, $2, $3)'

What’s the purpose of the second bounding box check? 

I did many tests. It’s always faster (about 20%) with one check. So we ended up using our own version of ST_DWithin.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20180106/4780afe8/attachment.html>

More information about the postgis-devel mailing list