Querying the size of a column family in RocksDB

1k Views Asked by At

Is there a way to know the size of all KVs that are stored in a column family?

2

There are 2 best solutions below

1
Jay Zhuang On
  1. For API you can use: GetApproximateSizes().

  2. 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.

  3. 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 setting statistics, like:

options.statistics = CreateDBStatistics()
1
keelar On

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.