[OSM-dev] Best and FASTEST Spatial DB for only calculating points near to X?

Ander Pijoan ander.pijoan at deusto.es
Fri Dec 14 20:42:20 GMT 2012

2012/12/14 Martin Schafran <martin at ampelmeter.com>

> use ssd,
> cluster nodes on spatial index,
> perform vacuum
> and show us your query.

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.

2012/12/14 Christian Vetter <veaac.fdirct at gmail.com>

> Hi,
> 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.
> E.g. consider a simple KD-Tree [1]:
> When doing you query you can simply stop recursion if the current block is
> completely within the given circle.
> 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.
> 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 :-)
> Best regards,
> Christian Vetter
> [1]: http://en.wikipedia.org/wiki/K-d_tree
> [2]:
> http://code.google.com/p/monav/source/browse/plugins/osmimporter/statickdtree.h
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20121214/a0d8b207/attachment.html>

More information about the dev mailing list