I am working on a problem where along with data points location, I also have information about the connectivity between points.(Think a graph of points, where an edge denotes some relationship)

My queries have to be optimized not just to find say 'Nearest Neighbors(NN)' or 'Reverse Nearest Neighbors(RNN)' but to find the points that satisfy NN/RNN along with the graph constraints.

It seems like I might need to modify the R-Tree index to store this additional information and perhaps even write a couple of my own routines to add some extra functionality.

Is there any way I can abstract the implementation of R-Tree by PostGIS and quickly extend it? Do I need to delve into the internals before I can get anything accomplished?

  • 1
    If you want to modify the tree, you'll have some serious internals-delving, not only into PostGIS but into PostgreSQL's GiST index types, to do. However, I think @LR1234567 may have a point, that these data might be orthogonal enough to permit you to use separate indexes - though perhaps not so efficiently. Unfortunately I don't think GiST indexes can be used in bitmap index scans, but a composite index may well work. – Craig Ringer Aug 16 '14 at 6:01

To building your graph you could try using ltree, a graph data type for PostgreSQL, then creating a compound gist index that contains both the geometry and ltree columns.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.