Hi Steven,<br><br>Thanks for the suggestion. I think it would work nicely on a more sophisticated db, but in my limited experience - MySQL is pretty dumb about running subqueries and you can end up with O(n2) run time. So it's better to stay with dumb joins unless OSM moves to something a little more heavyweight!<br>
<br>Alex<br><br><div class="gmail_quote">2008/5/30 Steven te Brinke <<a href="mailto:s.tebrinke@student.utwente.nl">s.tebrinke@student.utwente.nl</a>>:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
The second query uses a join only to select the correct values, not<br>
because you really want to join the tables. I think that you can achieve<br>
the same by a query like this:<br>
<br>
SELECT *<br>
FROM current_war_tags<br>
WHERE id IN (<br>
<div class="Ih2E3d"> SELECT *<br>
FROM current_ways<br>
WHERE tile IN (...)<br>
AND latitude BETWEEN ... AND ...<br>
AND longitude BETWEEN ... AND ...<br>
)<br>
ORDER BY id;<br>
<br>
</div>However, I do not know how the db handles subqueries. Thus, I am not<br>
sure if the performance of this query is better. But it seems to be a<br>
more logical way than using a join. (I am not very sure if using<br>
subqueries works at all, because I know some dbs have problems with that.)<br>
It might be worth trying.<br>
<br>
Steven<br>
<br>
<br>
Tom Hughes schreef:<br>
<div class="Ih2E3d">> You will get some duplication, yes. How much that matters will be<br>
> down to profiling as you say.<br>
><br>
> The other option is to run two queries in parallel:<br>
><br>
> SELECT *<br>
> FROM current_ways<br>
> WHERE tile IN (...)<br>
> AND latitude BETWEEN ... AND ...<br>
> AND longitude BETWEEN ... AND ...<br>
> ORDER BY id;<br>
><br>
> and:<br>
><br>
> SELECT cwt.*<br>
> FROM current_way_tags cwt<br>
> INNER JOIN current_ways cw ON <a href="http://cwt.id" target="_blank">cwt.id</a> = <a href="http://cw.id" target="_blank">cw.id</a><br>
> WHERE cw.tile IN (...)<br>
> AND cw.latitude BETWEEN ... AND ...<br>
> AND cw.longitude BETWEEN ... AND ...<br>
> ORDER BY <a href="http://cwt.id" target="_blank">cwt.id</a><br>
><br>
> then read both result sets at the same time and match them up.<br>
><br>
> Tom<br>
><br>
<br>
<br>
</div><div><div></div><div class="Wj3C7c">_______________________________________________<br>
dev mailing list<br>
<a href="mailto:dev@openstreetmap.org">dev@openstreetmap.org</a><br>
<a href="http://lists.openstreetmap.org/cgi-bin/mailman/listinfo/dev" target="_blank">http://lists.openstreetmap.org/cgi-bin/mailman/listinfo/dev</a><br>
</div></div></blockquote></div><br>