Have you looked at the nostrdb format?
Me and Mike Dilger ☑️ (npub1acg…p35c) also talked about this at nostrasia. You can either make it compact (varints) with an encoding/decoding step or flat/aligned with zero copy. I chose flat for query performance.
I think fiatjaf (npub180c…h6w6) also has one in his Go libraries somewhere.
