Is there a way to know the size of all KVs that are stored in a column family?
Asked
Active
Viewed 812 times
2 Answers
1
For API you can use:
GetApproximateSizes()
.If you just want to check, you can check RocksDB log, which has per column family
Compaction Stats
, which SST file size for each level.It's not reporting column family size, but if you're interested in bytes written, there's a statistic reporting that:
rocksdb.bytes.written
, you can get statistic by settingstatistics
, like:
options.statistics = CreateDBStatistics()

Jay Zhuang
- 321
- 4
- 9
-
Can you give an example of how to use `GetApproximateSizes()?` Specifically, if I want the size of the *entire* column, what do I use as a `Range`? – MyStackRunnethOver Sep 22 '21 at 18:53
1
If you want to know the total size of all SST files under a column family, a better way is via GetIntProperty(). In your case, you want to pass-in kTotalSstFileSize.
bool ok = db_->GetIntProperty(DB::Properties::kTotalSstFilesSize, &sst_size);
If you only care about the latest version of the SST files, then you should use kTotalLiveSstFileSize instead.

keelar
- 5,814
- 7
- 40
- 79
-
But how would this compare to `GetApproximateSizes` in terms of performance? Because with `GetApproximateSizes` you can decrease precision for a better performance, right? – luislhl Aug 10 '22 at 20:37