----
Hi Regina,
On 11/18/2016 3:28 AM, Regina Obe wrote:
Since you are doing 0.0, you might be better off using ST_Intersects
So
st_dwithin(pnt, a.geom, 0.0)
change to:
ST_Intersects(pnt,a.geom)
Did this change recently? I was under the impression that st_dwithin was
faster than st_intersects? Anyway, this is good to know, Thanks!
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.
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.
That said the main benefit of ST_Dwithin is
1) 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)
2) 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.
Hope that helps,
Regina
http://www.postgis.us
http://postgis.net
_______________________________________________
postgis-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/postgis-users