<div dir="ltr">Hi,<div><br></div><div>Try swapping arguments so that first one has index and second does not.<br><br>Speaking of "always 20% faster", what are the plans for your queries?</div></div><br><div class="gmail_quote"><div dir="ltr">сб, 6 янв. 2018 г. в 18:14, Zhihong Zhang <<a href="mailto:zhihong@gmail.com">zhihong@gmail.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">ST_DWithin is implemented like this,<div><br></div><div></div><div><table class="m_-3495747286198243415js-file-line-container m_-3495747286198243415highlight m_-3495747286198243415tab-size" style="box-sizing:border-box;border-spacing:0px;border-collapse:collapse;background-color:rgb(255,255,255)"><tr><td><font color="#24292e" face="Courier New"><span style="font-size:14px">CREATE OR REPLACE FUNCTION ST_DWithin(geom1 geometry, geom2 geometry, float8 RETURNS boolean</span></font></td></tr></table><table class="m_-3495747286198243415js-file-line-container m_-3495747286198243415highlight m_-3495747286198243415tab-size" style="box-sizing:border-box;border-spacing:0px;border-collapse:collapse;background-color:rgb(255,255,255)"><tr><td><font color="#24292e" face="Courier New"><span style="font-size:14px">AS 'SELECT $1 OPERATOR(@extschema@.&&) @extschema@.ST_Expand($2,$3) AND <b>$2 OPERATOR(@extschema@.&&) @extschema@.ST_Expand($1,$3)</b> AND @extschema@._ST_DWithin($1, $2, $3)'</span></font></td></tr></table><table class="m_-3495747286198243415js-file-line-container m_-3495747286198243415highlight m_-3495747286198243415tab-size" style="box-sizing:border-box;border-spacing:0px;border-collapse:collapse;background-color:rgb(255,255,255)"><tr><td><font color="#24292e" face="Courier New"><span style="font-size:14px">LANGUAGE 'sql' IMMUTABLE _PARALLEL;</span></font></td></tr></table><div><br></div></div><div>What’s the purpose of the second bounding box check? </div><div><br></div><div>I did many tests. It’s always faster (about 20%) with one check. So we ended up using our own version of ST_DWithin.</div><div><br></div><div>Thanks!</div><div><br></div><div>Zhihong</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div>_______________________________________________<br>
postgis-devel mailing list<br>
<a href="mailto:postgis-devel@lists.osgeo.org" target="_blank">postgis-devel@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/postgis-devel" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-devel</a></blockquote></div>