<br>Thanks Tom. I'll have a play with the various alternatives - and keep the code flexible enough to allow them to be swapped without much fuss.<br><br>Alex<br><br><div class="gmail_quote">2008/5/30 Tom Hughes <<a href="mailto:tom@compton.nu">tom@compton.nu</a>>:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">In message <<a href="mailto:44d06e000805300136g56758eefq1063ec0077f5a3c3@mail.gmail.com">44d06e000805300136g56758eefq1063ec0077f5a3c3@mail.gmail.com</a>><br>

<div class="Ih2E3d">        Alex Wilson <<a href="mailto:alex_wilson@pobox.com">alex_wilson@pobox.com</a>> wrote:<br>
<br>
</div><div class="Ih2E3d">> Ah. good point - a sensible third way. Apologies for missing it, I'm a<br>
> relative SQL novice. However, if you fetch the tags along with the ways<br>
> using a join, given that there are potentially many tags per way - couldn't<br>
> you end up with considerable duplication of the way data in the query<br>
> result? I suppose one would have to profile both the join method and my<br>
> local storage method to see which had better memory and time performance.<br>
<br>
</div>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>
<div><div></div><div class="Wj3C7c"><br>
Tom<br>
<br>
--<br>
Tom Hughes (<a href="mailto:tom@compton.nu">tom@compton.nu</a>)<br>
<a href="http://www.compton.nu/" target="_blank">http://www.compton.nu/</a><br>
</div></div></blockquote></div><br>