Skip to main content
For format-v2 databases (open a new database with Options.EnableMVCC), you can configure retention policies and prune old versions to reclaim space.

Overview

MVCC retains multiple versions of data for time-travel queries. Without pruning, the database grows unbounded. Retention policies control how much history to keep.

Configuring retention

Key points:
  • Retention is in commits, not wall-clock time
  • Zero (default) disables automatic suggestions
  • Only versions with strictly lower commit_seq than (header.CommitSeq - RetainCommitsBehindHead) may be reclaimed
  • Latest visible version per logical cell is never pruned

Mapping time to commits

Since retention is in commits, map your SLAs to commits based on observed commit rate:

Pruning APIs

Get MVCC statistics

Suggested prune sequence

Explicit prune

Prune with profile

Profiles:
  • PruneProfileLowLatency — Aggressive pruning, minimal history
  • PruneProfileBalanced — Default balance
  • PruneProfileLongHistory — Conservative pruning, more history

Prune scheduler

Note: No background goroutine runs inside the library. You control when pruning happens. Run pruning during low-traffic windows:

Pruning and compaction

Pruning marks versions as deleted but doesn’t immediately reclaim space. To reclaim space:

MVCC btree errors during prune

Signal: PruneCellVersions or StatsMVCC ascent fails mid-operation with engine errors. Response:
  • Stop writing
  • Backup files
  • Restore from known-good snapshot
  • Only use Update / primitives — avoid raw Tx.Put reordering cell/ vs __meta/commit-time/ keys on format v2

Performance considerations

  • Pruning overhead: Depends on version count and batch size
  • Batch size: Larger batches are more efficient but use more memory
  • Compaction: Required to reclaim space after pruning
  • Read performance: Unaffected by pruning (snapshot reads are fast)

Monitoring

Track these metrics:
  • VersionedRowCount — Total versioned rows (should stabilize with pruning)
  • LogicalCellCount — Unique cells (grows with data, not versions)
  • CommitSeq — Current commit sequence (monotonically increasing)

See also

  • MVCC — Multi-version concurrency control
  • Backups — Compaction and file management