mysqlhilbert-curve

Indexing based on Peano-hilbert curve?


I have a x,y,z 3D points stored in MySQL, I would like to ask the regions, slices or point neighbours. Are there way to index the points using Peano-Hilbert curves to accelerate the queries? Or are there more efficient way to store the 3D data in the MySQL?

thanks Arman.


Solution

  • I've personally never went this far, but I used a Z-curve to store 2D points. This worked quite well, and didn't feel the need to try to implement the hilbert curve for better results.

    This should allow you to quickly filter out points that certainly are not close by. In an absolute worst case scenario you still need to scan more than 25% of your table to find points within an area.

    The way to go about it is to split the x y z in binary and stitch them together into a single value using the curve. I wish I had a SQL script ready, but I just have one for the 2d z-curve which is a much much easier to do.

    Edit:

    Sorry you might already know all this already and really just looking for SQL samples, but I have some additions: