Maybe I'm old school but I would just stuff that kind of data in a struct. It should be real, real small as a packed binary tree. just mmap the file and be there. If you're never writing to it, or only write to it via filesystem full-file overwrites, you can lay it out most conveniently in memory. We did a similar thing with the sparse matrix data for the Netflix prize back in the day - in a database it was 6gb, in C structs it was ~600mb.
Of course I do respect the encapsulation of the existing SQL query basis but there is sometimes a time for something even more compact.
Yeah tempting for sure. I tried to resist it on the basis that I already have a bunch of similar solutions in the system, and while they're fast and effective, they're also always a bit of a headache to maintain and debug; and this isn't something that is extremely space constrained.
Of course I do respect the encapsulation of the existing SQL query basis but there is sometimes a time for something even more compact.