3 ms·
This could be added fairly trivially, however, and it is easy to emulate inside your app. You still get the efficiency that spatial indexing provides either wa
by jrockway 17y ago
This could be added fairly trivially, however, and it is easy to emulate inside your app. You still get the efficiency that spatial indexing provides either way.
From reading the documentation, this seems like a standard R-tree implementation, which is just a way to efficiently index two columns at once. If your dataset is two columns, x and y, a normal index could limit the xs efficiently, or limit the ys efficiently, but it couldn't limit both at the same time. This means you'd always have to do a scan over a large number of irrelevant records. The R-tree lets you get at the pair efficiently; you can get 2,2 without having to also look at 2,0; 2,1; 2,3; 2,... This is the performance benefit; if you want to know about all the coffee shops near 2,2, you can just retrieve 2,2 and not have to look at the rest of the dataset. If you need to implement wrapping, you can just retrieve the squares on the other side of the jump when someone requests records near the jump. This probably behaves differently for "things on earth" than on arbitrary two-dimensional datasets, so it is left as an exercise for the reader.
I assume. I have never had the occasion to implement (or even use) spatial indexes.