DeleteRange is an operation designed to replace the following pattern where a user wants to delete a range of keys in the range [start, end):

    1. ...
    2. Slice start, end;
    3. // set start and end
    4. auto it = db->NewIterator(ReadOptions());
    5.  
    6. for (it->Seek(start); cmp->Compare(it->key(), end) < 0; it->Next()) {
    7. db->Delete(WriteOptions(), it->key());
    8. }
    9. ...

    This pattern requires performing a range scan, which prevents it from being an atomic operation, and makes it unsuitable for any performance-sensitive write path. To mitigate this, RocksDB provides a native operation to perform this task:

    1. ...
    2. Slice start, end;
    3. // set start and end
    4. db->DeleteRange(WriteOptions(), start, end);
    5. ...

    Under the hood, this creates a range tombstone represented as a single kv, which significantly speeds up write performance. Read performance with range tombstones is competitive to the scan-and-delete pattern. (For a more detailed performance analysis, see the DeleteRange blog post.

    For implementation details, see this page.