[postgis-devel] ST_DWithin Performance

Darafei "Komяpa" Praliaskouski me at komzpa.net
Sat Jan 6 07:58:39 PST 2018


Hi,

Try swapping arguments so that first one has index and second does not.

Speaking of "always 20% faster", what are the plans for your queries?

сб, 6 янв. 2018 г. в 18:14, Zhihong Zhang <zhihong at gmail.com>:

> 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)'
> LANGUAGE 'sql' IMMUTABLE _PARALLEL;
>
> 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.
>
> Thanks!
>
> Zhihong
>
>
>
>
>
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20180106/f499b8db/attachment.html>


More information about the postgis-devel mailing list