Database / RocksDB Basics Interview Questions
What is Merge in RocksDB?
Merge is a special write operation that lets an application apply an incremental update to a key's value without first reading its current value.
- Common example: incrementing a counter, where you want to add a value rather than overwrite the whole thing
- Requires the application to supply a Merge Operator, custom logic defining how multiple pending merge operations should eventually be combined into a single value
- RocksDB defers actually applying the merge logic until a read happens or compaction processes the relevant data, rather than computing it immediately on every write
This operation avoids the classic read-modify-write pattern's overhead and potential race conditions, letting an application record "add 1" as its own lightweight write instead.
More Related questions...