Search code examples
c++databasekey-valuerocksdb

Effectirve rows removal in RocksDB


I need to loop over all key-values in RocksDB in order to fill my POD collection. I don't need to store key-values after retrieval. What should I use - DeleteRange() after loop or Delete() within loop? If it is DeleteRange(), then what end iterator must be passed as a parameter?

QScopedPointer<Iterator> it(m_db->NewIterator(ReadOptions()));
for (it->SeekToFirst(); it->Valid(); it->Next()) 
{
 // filling POD collection
}

Solution

  • You can use DeleteRange(start, end) where start is inclusive and end is exclusive. This is atomic and may be faster than using Delete() within loop.