[postgis-users] st_within too slow?
Pedro Doria Meunier
pdoria at netmadeira.com
Sat Aug 30 04:06:38 PDT 2008
Hi All,
I was using the legacy operator && for determining if a point was inside
a particular geometry as thus:
SELECT road_network, toponymy FROM maps AS m WHERE m.b_box &&
geomfromtext('POINT($lon $lat)',4326)
When I was faced with two geometries such as Portugal and Spain country
boundaries I began always getting the row for Spain when I was trying to
get the map of Portugal for a point inside it.
It led me to the conclusion that the && operates as a bounding box for
the corresponding geometry where, in this particular case, the bounding
box of Spain *overlaps* the one of Portugal.
So I was forced to update the query to this:
SELECT road_network, toponymy FROM maps AS m WHERE
st_within(geomfromtext('POINT($lon $lat)',4326), m.b_box)
It works but with a catch: it takes ~200ms where the && took
~25ms ... :-(
Before you ask: yes, I've created the correspondent indices using gist.
Is there any way I can work around this or optimize it?
P.S. I'm using PostgreSQL 8.2.9 on x86_64, PostGIS 1.3.3, geos 2.2.3,
proj 4.5.0
Thank you in advance for any insight on the matter.
Regards,
--
Pedro Doria Meunier <pdoria at netmadeira.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20080830/bd409e00/attachment.pgp>
More information about the postgis-users
mailing list