Hi Alan.<br><br>Also I'm not sure if the <span style="font-style: italic;">"service1 c, service1 d"</span> and the <span style="font-style: italic;">"AND c.service_id <> d.service_id"</span> parts are right. I'm not sure but sinse you don't uses this two tables in your query you can remove that parts of your query and it can be faster cause otherwise this two tables will be combined as cartesian product with the others and I don't think this is what you want. (I'm not pretty sure but I think this is what will happen if you do not remove that parts of your querys).
<br><br>Rodrigo.<br><br><div><span class="gmail_quote">On 7/10/07, <b class="gmail_sendername">Paul Ramsey</b> <<a href="mailto:pramsey@refractions.net">pramsey@refractions.net</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Try this:<br><br>CREATE table topology (stop_a, stop_b, distance)<br>AS SELECT DISTINCT a.stop_reference, b.stop_reference,<br>distance(a.east_north, b.east_north)<br>FROM bus_stops1 a, bus_stops1 b, service1 c, service1 d
<br>WHERE distance(a.east_north, b.east_north) < 200<br>AND expand(a.east_north, 200) && b.east_north<br>AND a.stop_reference <> b.stop_reference<br>AND c.service_id <> d.service_id<br>ORDER BY distance;
<br><br>--<br><br>   Paul Ramsey<br>   Refractions Research<br>   <a href="http://www.refractions.net">http://www.refractions.net</a><br>   <a href="mailto:pramsey@refractions.net">pramsey@refractions.net</a><br>   Phone: 250-383-3022
<br>   Cell: 250-885-0632<br>_______________________________________________<br>postgis-users mailing list<br><a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br><a href="http://postgis.refractions.net/mailman/listinfo/postgis-users">
http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br></blockquote></div><br>