Record layer: getting the db size of a given record type

Is there a way to get a close approximation of a size of all keys (or values) for a given record type?

I see SizeStatisticsCollector but this is essentially iterating all records right? I just need a close approximation of the size for a given record type.

The size statistics collector is the only way to get the exact answer. As far as I know, it should work on all schemas, though it does require iterating over all of the records.

For an approximate answer, you could use FDBRecordStore::estimateRecordSize. That method takes a TupleRange and tells you how many bytes the range covers (adding key bytes and value bytes) using the same FDB size estimate features that are also used for things like balancing data between FDB servers. This won’t tell you how large the indexes on the type are, and it will only work well if all of the records of a given type are stored under a common prefix (e.g., if all of the record primary keys are prefixed by a recordType() key expression à la fdb-record-layer/docs/FAQ.md at main · FoundationDB/fdb-record-layer · GitHub).