Best practice of storing structs. Should I pack or store fields separately

Presumably you’ll need to index at least some of those fields for individual lookups rather than doing a full range scan. A good compromise would be to store the entire document serialized (whatever works for you) and then add indexes as other keys with a pointer back to the original serialized record as the value.

Additionally, if your workload involves frequent updates to individual properties of a record rather than re-writing the entire thing, it may be worth breaking out some of the fields into their own keys to make updates involve less IO.

E.g.

Data: users/data/1 => name:john, age:34
Index: users/index/age/34 => 1

1 Like