Buffered upsert
A buffered upsert encodes a deferred transformation of a key's value without first fetching that value.
In B-epsilon trees, pending transformations must be applied in insertion order when the key is queried or the messages reach its leaf. This is not simply SQL insert-or-update syntax, and it does not by itself specify transaction isolation or durable acknowledgement. [1]
An upsert message carries the key, a callback function and auxiliary data. When it is flushed to the leaf, the stored value is replaced by the callback result and the message is discarded. A query that arrives first applies the pending messages found on the root-to-leaf path. Tombstones are a special case, and counters or access times are other examples. [1]
The primer reports nodes of about 4 MB, branching factors from 4 to 16 and batches of at least 256 KB in its implementations. Its query argument concerns I/O along the existing search path: pending callbacks do not require an extra node path. This is not a guarantee of unchanged elapsed latency; callback CPU work, message count and contention still matter. [1]
A write-optimized research file system from 2015 turns most metadata changes and partial block writes into upserts, avoiding a read-modify-write for each small write. [3]
Relations
- related
- B-epsilon tree, Log-structured merge-tree, LSM tombstone, Range rename, Late-binding journal, BetrFS, Write-optimized dictionary, TokuFS
Advantages
- Makes extra secondary indexes cheap to maintain, because each index update becomes a buffered insert rather than a query. [1]
Limitations
- The 2015 prototype's per-block deletion cost is version-specific, not an inherent requirement of every buffered index. [3]
- The caller must be able to proceed without the computed result to retain the benefit of a blind update; returning the old value requires obtaining it. [4]
Citations
- Bender, Farach-Colton, Jannen, Johnson, Kuszmaul, Porter, Yuan and Zhan. An Introduction to B-epsilon-trees and Write-Optimization. ;login: 40(5), 2015.
- Jannen et al. BetrFS: A Right-Optimized Write-Optimized File System. FAST 2015, pp. 301-315, sections 2-4.
- BetrFS authors. Frequently Asked Questions, upserts and blind writes; historical prototype guidance, not a current-release specification.
Further reading
Sources & caveats
- primer is Bender et al., ;login: October 2015. Basic operations and upserts, pp. 22-26, rechecked on 2026-10-23.
- betrfs is Jannen et al., FAST 2015, read in sections 2 to 4.
- The node and batch figures are historical implementation descriptions in primer. Its query-performance argument concerns I/O; no new elapsed-time benchmark or speedup estimate is supplied.