简体   繁体   中英

How rocksdb delete key works

I'm trying to learn how rocksdb works under the hood. I understand that each SST file has a bloom filter, to indicate whether a key belongs to the file or not. But what happens when a key is deleted from the file? Bloom filter doesn't support deletions so a new bloom filter is created instead?

If a key is deleted, RocksDB creates a deletion marker (tombstone) for it, which is later persisted in SST files. Tombstones in an SST file will be added to the file's bloom filter.

bloom filter, to indicate whether a key belongs to the file or not.

The bloom filter is to speed up the check whether a key is contained in the file or not. That is why the api is called keyMayExist since it is probabilistic

Bloom filter doesn't support deletions so a new bloom filter is created instead?

No - nothing to do with bloom filters

what happens when a key is deleted from the file

First it is deleted from the memtable and when the data is flushed to disk a marker is stored that key xyz has been deleted

I'm trying to learn how rocksdb works under the hood.

Watch the video https://youtu.be/7QHI7JQEc5c?t=1281

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM