Friday, August 20, 2010

ST_Intersects and ST_Buffer: No

If you find yourself writing a query like this:

... WHERE ST_Intersects(ST_Buffer(g1, r), g2)

Stop. Take a cleansing breath. Do this:

... WHERE ST_DWithin(g1, g2, r)

With the carbon emissions you save doing it the efficient way, you can afford to drive to the ice cream store for a well-deserved reward.
 

2 comments:

KG said...

Sure - semantically nice and easy, but way slower on a large dataset. Comparative figures

st_intersects(st_buffer ... - 1.5sec
st_dwithin( ..., 0) - 4.5 secs

Paul Ramsey said...

There's something very non-normal about your data or index set-up or something.

About Me

My Photo
Victoria, British Columbia, Canada

Followers

Blog Archive

Labels