<div class="gmail_quote">2012/12/14 Martin Schafran <span dir="ltr"><<a href="mailto:martin@ampelmeter.com" target="_blank">martin@ampelmeter.com</a>></span><br><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">
use ssd,<br>cluster nodes on spatial index,<br>perform vacuum<br>and show us your query.<br></blockquote><div> </div><div>Thanks a lot for the advice. The query as I previously mentioned it would be as simple as a "SELECT * FROM db WHERE X=X AND DISTANCE<5km". There wouldn't be more type of queries. </div>
<div> </div><div> </div></div><div class="gmail_quote">2012/12/14 Christian Vetter <span dir="ltr"><<a href="mailto:veaac.fdirct@gmail.com" target="_blank">veaac.fdirct@gmail.com</a>></span><br><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">
<p>Hi,<br><br>If the only thing you are interested in is asking for the amount of points within a given radius, I would strongly advise not to use a database, but quickly implement a dedicated data structure for that. That can usually be an order of magnitude faster than a general purpose database.<br>
<br>E.g. consider a simple KD-Tree [1]:<br><br>When doing you query you can simply stop recursion if the current block is completely within the given circle.<br>You can implement a KD-Tree in a really lightweight manner, completely implicitly. Just storing the coordinates, the KD-Tree structure is encoded in the ordering of them. You can have a look at an example [2]: Have a look at the function NearNeighbors, it could easily be modified to count the amount of points instead of returning them.<br>
<br>The only reason I could think of for using a database is, that you have to handle much more data than fits into memory. However, even in that case a specialized data structure should perform better - it's only more effort to implement :-)<br>
<br>Best regards,<br><br>Christian Vetter<br><br>[1]: <a href="http://en.wikipedia.org/wiki/K-d_tree" target="_blank">http://en.wikipedia.org/wiki/K-d_tree</a><br>[2]: <a href="http://code.google.com/p/monav/source/browse/plugins/osmimporter/statickdtree.h" target="_blank">http://code.google.com/p/monav/source/browse/plugins/osmimporter/statickdtree.h</a></p>
<p> </p></blockquote><div>Hmmm, didn't thought about this. I don't know about K-D trees but I will search for information about it. Thank you very much.</div></div><br>