Posts tagged with 'ST_DWithin'

Distance proximity: Use ST_DWithin not Distance

If you have a problem that involves finding the things within X distance of other things or finding what things have nothing within X distance do not use ST_Distance for filtering and also do not try to use ST_Intersects + ST_Buffer.
Use ST_DWithin instead. Why?

  1. ST_DWithin can use an index and ST_Distance can not

  2. ST_Buffer is just an approximation of a buffer and not an exact buffer

Also note that ST_DWithin is supported for both geometry and geography.

Read More…