Thanks all. Both these solutions work for me.<br><br><div class="gmail_quote">On Tue, Sep 27, 2011 at 10:23 PM, Stephen Woodbridge <span dir="ltr"><<a href="mailto:woodbri@swoodbridge.com">woodbri@swoodbridge.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi Paul,<br>
<br>
If the pipeline is a very long linestring then would it make sense to first chop the linestring into multiple shorter segments and then intersect each of them against the roads. I would think that this could be done with a join between SRF to chop the linestring into segments and the roads table.<br>

<br>
I would have to think about the SQL to do this a little bit, but I think this would be faster still. Thoughts?<br>
<br>
-Steve<div><div></div><div class="h5"><br>
<br>
On 9/27/2011 5:11 PM, Paul Ramsey wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<a href="http://www.sql-tutorial.net/SQL-JOIN.asp" target="_blank">http://www.sql-tutorial.net/<u></u>SQL-JOIN.asp</a><br>
<br>
SELECT ST_AsText(ST_Intersection(r.<u></u>the_geom, p.the_geom)<br>
FROM roads r JOIN pipes p ON ST_Intersects(r.the_geom, p.the_geom)<br>
WHERE p.pipeid = 1;<br>
<br>
<br>
On Tue, Sep 27, 2011 at 1:56 PM, <a href="mailto:vinod.khare@gmail.com" target="_blank">vinod.khare@gmail.com</a><br>
<<a href="mailto:vinod.khare@gmail.com" target="_blank">vinod.khare@gmail.com</a>>  wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I have a table containing all roads in the US. Naturally, this table is very<br>
large with more that 20 million rows. I want to find the intersection of<br>
these roads with a single linestring (representing a pipeline).<br>
<br>
SELECT ST_AsText(ST_Intersection(<br>
     (SELECT the_geom FROM roads)<br>
     (SELECT the_geom FROM pipes WHERE pipeid = 1)));<br>
<br>
I have created a gist index on roads but the query planner does not use it.<br>
The query takes a really long time. Is there some way to optimize this?<br>
<br>
thanks,<br>
Vinod.<br>
<br>
______________________________<u></u>_________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@postgis.refractions.net" target="_blank">postgis-users@postgis.<u></u>refractions.net</a><br>
<a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.<u></u>net/mailman/listinfo/postgis-<u></u>users</a><br>
<br>
<br>
</blockquote>
______________________________<u></u>_________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@postgis.refractions.net" target="_blank">postgis-users@postgis.<u></u>refractions.net</a><br>
<a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.<u></u>net/mailman/listinfo/postgis-<u></u>users</a><br>
</blockquote>
<br>
______________________________<u></u>_________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@postgis.refractions.net" target="_blank">postgis-users@postgis.<u></u>refractions.net</a><br>
<a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.<u></u>net/mailman/listinfo/postgis-<u></u>users</a><br>
</div></div></blockquote></div><br>