Have you looked at the nostrdb format?
Me and nostr:npub1acg6thl5psv62405rljzkj8spesceyfz2c32udakc2ak0dmvfeyse9p35c 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 nostr:npub180cvv07tjdrrgpa0j7j7tmnyl2yr6yr7l8j4s3evf6u64th6gkwsyjh6w6 also has one in his Go libraries somewhere.