<div dir="ltr">Thanks Regina,<div><br></div><div>even if it doesn't help Stephen all that much, it is helpful to me !</div><div><br></div><div>cheers</div><div><br></div><div>Ben</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 19 November 2016 at 19:44, Regina Obe <span dir="ltr"><<a href="mailto:lr@pcorp.us" target="_blank">lr@pcorp.us</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div class="m_-5513676788670526110WordSection1"><div><div><p class="MsoNormal" style="margin-left:59.1pt"><br><span style="color:#1f497d">----</span><span class=""><br><br>Hi Regina,<br><br>On 11/18/2016 3:28 AM, Regina Obe wrote:<u></u><u></u></span></p><span class=""><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in"><p class="MsoNormal" style="margin-left:59.1pt">Since you are doing 0.0, you might be better off using ST_Intersects<br><br>So<br><br>st_dwithin(pnt, a.geom, 0.0)<br><br>change to:<br><br>ST_Intersects(pnt,a.geom)<u></u><u></u></p></blockquote><p class="MsoNormal" style="margin-right:0in;margin-bottom:12.0pt;margin-left:59.1pt"><br>Did this change recently? I was under the impression that st_dwithin was<br>faster than st_intersects? Anyway, this is good to know, Thanks!<u></u><u></u></p><p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p></span><p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">                              <wbr>                  No it didn't, ST_Intersects has generally always been faster.  In most cases ST_Intersects is faster than ST_DWithin since it can take advantage of certain topological features of a geometry, so it not quite as sensitive to the number of points as ST_DWithin is.  It also supports prepared geometry.  Paul can correct me, but I don't think we've added prepared geometry support for ST_DWithin. That means it should perform much better when comparing a biggo single geometry against a lot of different geometries.<u></u><u></u></span></p><p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">ST_DWithin was much slower until Nicklas made some major improvements a while back which increased the speed I think 10 fold, making it in many cases almost as fast and sometimes faster than ST_Intersects.<u></u><u></u></span></p><p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">That said the main benefit of ST_Dwithin is <u></u><u></u></span></p><p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p><p class="m_-5513676788670526110MsoListParagraph" style="margin-bottom:12.0pt"><u></u><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><span>1)<span style="font:7.0pt "Times New Roman"">      </span></span></span><u></u><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">You can provide a tolerance which you can't with ST_Intersects, and it will short-circuit if it hits that tolerance (doesn't need to compute full distance)<u></u><u></u></span></p><p class="m_-5513676788670526110MsoListParagraph" style="margin-bottom:12.0pt"><u></u><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><span>2)<span style="font:7.0pt "Times New Roman"">      </span></span></span><u></u><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">It doesn't care if your geometry is invalid, where as ST_Intersects will often throw up its hands and throw false in your face regardless how close the geometries are because the DEIM it relies on needs the geometries to be valid.<u></u><u></u></span></p><p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Hope that helps,<u></u><u></u></span></p><p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Regina<u></u><u></u></span></p><p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><a href="http://www.postgis.us" target="_blank">http://www.postgis.us</a><u></u><u></u></span></p><p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><a href="http://postgis.net" target="_blank">http://postgis.net</a><u></u><u></u></span></p><p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p></div></div></div></div><br>______________________________<wbr>_________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">http://lists.osgeo.org/<wbr>mailman/listinfo/postgis-users</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><br></div><div>Ben Madin</div><div><br></div><div><img src="https://docs.google.com/uc?export=download&id=0B0tCyjHjhebBaXJlcV93aEd0bkE&revid=0B0tCyjHjhebBTk9FR3Q5Z29lakFxd1BEUGxVN1B0MjNQNkJFPQ"><br></div><div><br></div><div>m : +61 448 887 220<span style="white-space:pre">       </span>t : +61 8 9336 5022</div><div><br></div><div>e : <a href="mailto:ben@ausvet.com.au" target="_blank">ben@ausvet.com.au</a></div><div><br></div><div>10 High Street, Fremantle</div><div>Western Australia</div><div><br></div><div>find us: <a href="http://w3w.co/duke.basket.decks" target="_blank">http://w3w.co/duke.basket.decks</a></div><div><br></div><div>on the web: <a href="http://www.ausvet.com.au" target="_blank">www.ausvet.com.au</a></div><div><br></div><div><br></div><div>This transmission is for the intended addressee only and is confidential information. If you have received this transmission in error, please delete it and notify the sender. The contents of this email are the opinion of the writer only and are not endorsed by Ausvet unless expressly stated otherwise. Although Ausvet uses virus scanning software we do not accept liability for viruses or similar in any attachments. Thanks for reading.</div></div></div></div></div>
</div>