[postgis-users] st_within too slow? -- room for developmentimprovement?

Obe, Regina robe.dnd at cityofboston.gov
Tue Sep 2 05:51:53 PDT 2008


Dear Regina,

> Thanks for your suggestion :)
> The thing is that using st_intersects doesn't help. :-(
> The performance is exactly the same which actually puzzles me for
> functions (namely ST_Within) that should return almost instantly ...
> Problem being that as far as I can see there's no other function that
> replaces these for the same effect...

Pedro,
You could try ST_DWithin.  It could be that since your geometries are so
big and possibly complex - the penalty of crossing the Geos barrier is
very high. 

ST_DWithin as I recall doesn't use Geos so may just perform better in
this case.

Try

SELECT road_network, toponymy FROM maps AS m WHERE
st_dwithin(ST_geomfromtext('POINT($lon $lat)',4326), m.b_box, 0.001)

Note - I had to do a 0.001 proximity since ST_Dwithin does an internal
distance < whatever you put in.  You can make this even smaller.
Why is it called b_box (is it really a bbox or a complex geometry? If it
is a bbox not sure the point of not just doing a &&)


>(Call to developers)
>This leads me to asking: isn't there room for improvement in these
>functions?

Yap room for lots of improvement in GEOS and don't worry we are working
on it.
As Paul Ramsey mentioned there is the PreparedGeometry which is in the
works which should help large geometries.  There is also cleanup going
on with other inefficiencies.

Thanks,
Regina

-----------------------------------------
The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure
pursuant to Massachusetts law. It is intended
solely for the addressee. If you received this in error, please
contact the sender and delete the material from any computer.




More information about the postgis-users mailing list