Multi-version Concurrency Control
Multi-version Concurrency Control (MVCC) is a database concurrency control method that allows multiple versions of data to exist simultaneously, enabling readers to see a consistent snapshot without blocking writers. Each transaction works with a version of the database as it existed at the start of the transaction, while allowing other transactions to create new versions concurrently.
How MVCC works
MVCC maintains multiple versions of each data record, each tagged with transaction timestamps or version numbers. When a transaction modifies data:
- A new version is created rather than overwriting existing data
- The old version is retained for ongoing transactions that might need it
- Each transaction sees a consistent snapshot based on its start time
Next generation time-series database
QuestDB is an open-source time-series database optimized for market and heavy industry data. Built from scratch in Java and C++, it offers high-throughput ingestion and fast SQL queries with time-series extensions.
Benefits in time-series systems
In time-series databases, MVCC is particularly valuable because:
- Time-series data is often append-heavy with concurrent reads
- Historical queries need consistent point-in-time views
- Real-time analytics require isolation from ongoing writes
For example, a financial system can simultaneously:
- Ingest live market data
- Run historical analysis
- Serve real-time dashboards
Each operation sees a consistent version of the data without blocking others.
Next generation time-series database
QuestDB is an open-source time-series database optimized for market and heavy industry data. Built from scratch in Java and C++, it offers high-throughput ingestion and fast SQL queries with time-series extensions.
Version cleanup and storage considerations
MVCC systems must manage version cleanup (vacuum) to prevent unbounded storage growth:
- Track the oldest active transaction
- Identify versions no longer visible to any transaction
- Remove obsolete versions while maintaining referential integrity
The cleanup process balances:
- Storage efficiency
- Query performance
- Transaction isolation guarantees
Implementation approaches
Modern databases implement MVCC through various strategies:
- Append-only storage: New versions are appended to tables or write-ahead logs
- Time-travel storage: Versions are organized by timestamp for efficient historical access
- Delta storage: Only changes are stored between versions
These approaches often combine with other features like snapshot isolation for additional consistency guarantees.