<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7652.24">
<TITLE>RE: [postgis-users] st_within too slow?</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>Pedro,<BR>
<BR>
Try using st_intersects instead of ST_within.  In general I think it performs better than within and for point in poly will be just as good.<BR>
<BR>
Yah Guido's suggestion would be at best give same timing since ST_Within, ST_Intersects have an implicit && call in them so they can limit the number of more painful _ST_Within, _ST_Intersects checks they actually need to do.<BR>
<BR>
Hope that helps,<BR>
Regina<BR>
<BR>
<BR>
<BR>
-----Original Message-----<BR>
From: postgis-users-bounces@postgis.refractions.net on behalf of Pedro Doria Meunier<BR>
Sent: Sat 8/30/2008 8:16 AM<BR>
To: PostGIS Users Discussion<BR>
Subject: RE: [postgis-users] st_within too slow?<BR>
<BR>
Dear Guido,<BR>
<BR>
Thanks for replying.<BR>
Your suggested mod actually worsens the performance by another ~15-20ms<BR>
<BR>
Best regards,<BR>
--<BR>
Pedro Doria Meunier <pdoria@netmadeira.com><BR>
<BR>
> Pedro,<BR>
><BR>
> Try this instead:<BR>
><BR>
> SELECT road_network, toponymy FROM maps AS m WHERE m.b_box &&<BR>
> geomfromtext('POINT($lon $lat)',4326) and<BR>
> st_within(geomfromtext('POINT($lon $lat)',4326), m.b_box)<BR>
><BR>
> of course, if you already know that the point is in Portugal,<BR>
> you could do:<BR>
><BR>
> SELECT road_network, toponymy FROM maps AS m WHERE<BR>
> m.country = 'PT' and<BR>
> m.b_box && geomfromtext('POINT($lon $lat)',4326)<BR>
><BR>
> (assuming that the maps table has the 'country' column with<BR>
> country names).<BR>
><BR>
> GL<BR>
<BR>
<BR>
</FONT>
</P>

</BODY>
</HTML>
<HTML><BODY><P><hr size=1></P>
<P><STRONG>
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.
</STRONG></P></BODY></HTML>

<P><hr size=1></P>
<P><STRONG><font size="2" color="339900"> Help make the earth a greener place. If at all possible resist printing this email and join us in saving paper. </p> <p> </font></STRONG></P>