DriftDB - An experimental append-only database with built-in time travel. Query any point in history, guaranteed data integrity, and immutable audit trails. Written in Rust.
See the codeExperimental PostgreSQL-Compatible Time-Travel Database (v0.9.1-alpha) - An ambitious temporal database project with advanced architectural designs for enterprise features. Query your data at any point in history using standard SQL.
⚠️ ALPHA SOFTWARE - NOT FOR PRODUCTION USE: This version contains experimental implementations of enterprise features. The codebase compiles cleanly with zero warnings and includes comprehensive CI with security auditing. Many advanced features remain as architectural designs requiring implementation.
Experience DriftDB's time-travel capabilities right now!
cd demo
./run-demo.sh
# Opens at http://localhost:8080
Or simply open demo/index.html in your browser - no installation required!
The interactive demo features:
# Start the PostgreSQL-compatible server
./target/release/driftdb-server --data-path ./data
# Connect with any PostgreSQL client
psql -h localhost -p 5433 -d driftdb
# Use standard SQL with time-travel
CREATE TABLE events (id INT PRIMARY KEY, data VARCHAR);
INSERT INTO events (id, data) VALUES (1, 'original');
UPDATE events SET data = 'modified' WHERE id = 1;
-- Query historical state!
SELECT * FROM events FOR SYSTEM_TIME AS OF @SEQ:1; -- Shows 'original'
SELECT * FROM events; -- Shows 'modified'
FOR SYSTEM_TIME AS OF for querying historical statesFOR SYSTEM_TIME AS OF: Query data at any point in time — accepts both ISO-8601 timestamps and DriftDB's @SEQ:N extension, and resolves correctly through both the CLI/server SQL path and the read-only engine API used by FK validationFOR SYSTEM_TIME ALL: Complete history of changesFOR SYSTEM_TIME BETWEEN and FOR SYSTEM_TIME FROM ... TO are parsed but not yet executable — they return a clear "not yet supported" error rather than silently dropping the clause. Implementing them needs a range-aware engine query variant; tracked as a follow-up.=, !=, <, <=, >, >=; the parallel path (used automatically for larger result sets) also handles LIKE, IN, NOT IN, and non-numeric ordering. Same query can return different rows depending on table size. Consolidating the two implementations is on the roadmap.The following features have been architecturally designed with varying levels of implementation:
# Quick start with Docker
git clone https://github.com/DavidLiedle/DriftDB.git
cd DriftDB
./scripts/docker-quickstart.sh
# Connect to DriftDB
psql -h localhost -p 5433 -d driftdb -U driftdb
# Set DRIFTDB_PASSWORD env var, or check server logs for generated password
# Clone and build from source
git clone https://github.com/DavidLiedle/DriftDB.git
cd DriftDB
make build
# Or install the binaries with cargo (these crates are not on crates.io;
# `driftdb-server` there is an unrelated project)
cargo install --path crates/driftdb-cli && cargo install --path crates/driftdb-server
# Run the full demo (creates sample data and runs queries)
make demo
# Demo includes:
# - Database initialization
# - Table creation with 10,000 sample orders
# - SELECT queries with WHERE clauses
# - Time-travel queries (FOR SYSTEM_TIME AS OF @SEQ:N)
# - Snapshot and compaction operations
DriftDB now includes a PostgreSQL wire protocol server, allowing you to connect with any PostgreSQL client:
# Start the server
./target/release/driftdb-server
# Connect with psql
psql -h 127.0.0.1 -p 5433 -d driftdb -U driftdb
# Connect with any PostgreSQL driver (set DRIFTDB_PASSWORD or check logs)
postgresql://driftdb:<password>@127.0.0.1:5433/driftdb
The server supports:
# Initialize database
driftdb init ./mydata
# Check version
driftdb --version
# Execute SQL directly
driftdb sql -d ./mydata -e "CREATE TABLE users (id INTEGER, email VARCHAR, status VARCHAR, PRIMARY KEY (id))"
# Or use interactive SQL file
driftdb sql -d ./mydata -f queries.sql
-- Create a temporal table
CREATE TABLE users (
id INTEGER,
email VARCHAR,
status VARCHAR,
created_at VARCHAR,
PRIMARY KEY (id)
);
-- Insert data
INSERT INTO users VALUES (1, 'alice@example.com', 'active', CURRENT_TIMESTAMP);
-- Standard SQL queries with WHERE clauses
SELECT * FROM users WHERE status = 'active';
SELECT * FROM users WHERE id > 100 AND status != 'deleted';
-- UPDATE with conditions
UPDATE users SET status = 'inactive' WHERE last_login < '2024-01-01';
-- DELETE with conditions (soft delete preserves history)
DELETE FROM users WHERE status = 'inactive' AND created_at < '2023-01-01';
-- Time travel query (SQL:2011)
SELECT * FROM users
FOR SYSTEM_TIME AS OF '2024-01-15T10:00:00Z'
WHERE id = 1;
-- Query all historical versions
SELECT * FROM users
FOR SYSTEM_TIME ALL
WHERE id = 1;
-- Advanced SQL Features (v0.6.0)
-- Column selection
SELECT name, email FROM users WHERE status = 'active';
-- Aggregation functions
SELECT COUNT(*) FROM users;
SELECT COUNT(email), AVG(age) FROM users WHERE status = 'active';
SELECT MIN(created_at), MAX(created_at) FROM users;
-- GROUP BY and aggregations
SELECT status, COUNT(*) FROM users GROUP BY status;
SELECT department, AVG(salary), MIN(salary), MAX(salary)
FROM employees GROUP BY department;
-- HAVING clause for group filtering
SELECT department, AVG(salary) FROM employees
GROUP BY department HAVING AVG(salary) > 50000;
-- ORDER BY and LIMIT
SELECT * FROM users ORDER BY created_at DESC LIMIT 10;
SELECT name, email FROM users WHERE status = 'active'
ORDER BY name ASC LIMIT 5;
-- Complex queries with all features
SELECT department, COUNT(*) as emp_count, AVG(salary) as avg_salary
FROM employees
WHERE hire_date >= '2023-01-01'
GROUP BY department
HAVING COUNT(*) >= 3
ORDER BY AVG(salary) DESC
LIMIT 5;
-- AS OF: Query at a specific point in time
SELECT * FROM orders
FOR SYSTEM_TIME AS OF '2024-01-15T10:30:00Z'
WHERE customer_id = 123;
-- AS OF @SEQ:N: DriftDB extension — query by sequence number
SELECT * FROM orders
FOR SYSTEM_TIME AS OF @SEQ:5000
WHERE customer_id = 123;
-- ALL: Complete history
SELECT * FROM audit_log
FOR SYSTEM_TIME ALL
WHERE action = 'DELETE';
FOR SYSTEM_TIME BETWEEN ... AND ... and FOR SYSTEM_TIME FROM ... TO ... are
parsed but not yet executable — they return a clear "not yet supported" error
rather than silently dropping the clause. Tracking implementation as a follow-up.
-- Create table with system versioning (standard SQL syntax)
CREATE TABLE orders (
id VARCHAR PRIMARY KEY,
status VARCHAR,
customer_id VARCHAR,
amount INTEGER
);
-- Insert data
INSERT INTO orders VALUES ('order1', 'pending', 'cust1', 100);
-- Update with conditions
UPDATE orders SET status = 'paid' WHERE id = 'order1';
-- Delete (soft delete preserves history for time-travel)
DELETE FROM orders WHERE id = 'order1';
-- Start a transaction
BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ;
-- Multiple operations in transaction
INSERT INTO orders VALUES ('order2', 'pending', 'cust2', 200);
UPDATE orders SET status = 'shipped' WHERE id = 'order1';
-- Commit or rollback
COMMIT;
-- or
ROLLBACK;
-- Query historical state by timestamp
SELECT * FROM orders FOR SYSTEM_TIME AS OF '2025-01-01T00:00:00Z' WHERE status = 'paid';
-- Query by sequence number
SELECT * FROM orders FOR SYSTEM_TIME AS OF @SEQ:1000 WHERE customer_id = 'cust1';
-- Show complete history of a record (CLI command)
driftdb drift -d ./data --table orders --key "order1"
-- Add a new column with default value
ALTER TABLE orders ADD COLUMN priority VARCHAR DEFAULT 'normal';
-- Add an index
CREATE INDEX idx_orders_created ON orders(created_at);
-- Drop a column
ALTER TABLE orders DROP COLUMN legacy_field;
# Create snapshot for performance
driftdb snapshot -d ./data --table orders
# Compact storage
driftdb compact -d ./data --table orders
# Check database integrity
driftdb doctor -d ./data
# Show table statistics
driftdb analyze -d ./data --table orders
data/
tables/<table>/
schema.yaml # Table schema definition
segments/ # Append-only event logs with CRC32
00000001.seg
00000002.seg
snapshots/ # Compressed materialized states
00000100.snap
indexes/ # Secondary B-tree indexes
status.idx
customer_id.idx
meta.json # Table metadata
wal/ # Write-ahead log for durability
wal.log
wal.log.1 # Rotated WAL files
migrations/ # Schema migrations
history.json
pending/
backups/ # Backup snapshots
[u32 length][u32 crc32][varint seq][u64 unix_ms][u8 event_type][msgpack payload]
-- "Prove we had user consent when we sent that email"
SELECT consent_status, consent_timestamp
FROM users
FOR SYSTEM_TIME AS OF '2024-01-15T14:30:00Z'
WHERE email = 'user@example.com';
-- "What was the state when the error occurred?"
SELECT * FROM shopping_carts
FOR SYSTEM_TIME AS OF '2024-01-15T09:45:00Z'
WHERE session_id = 'xyz-789';
-- "Show me how this metric changed over time"
SELECT DATE(SYSTEM_TIME_START) as date, COUNT(*) as daily_users
FROM users
FOR SYSTEM_TIME ALL
WHERE status = 'active'
GROUP BY DATE(SYSTEM_TIME_START);
-- "Restore accidentally deleted data"
INSERT INTO users
SELECT * FROM users
FOR SYSTEM_TIME AS OF '2024-01-15T08:00:00Z'
WHERE id NOT IN (SELECT id FROM users);
| Feature | DriftDB | PostgreSQL | MySQL | Oracle | SQL Server |
|---|---|---|---|---|---|
| SQL:2011 Temporal | ✅ Native | ⚠️ Extension | ❌ | 💰 Flashback | ⚠️ Complex |
| Storage Overhead | ✅ Low (events) | ❌ High | ❌ High | ❌ High | ❌ High |
| Query Past Data | ✅ Simple SQL | ❌ Complex | ❌ | 💰 Extra cost | ⚠️ Complex |
| Audit Trail | ✅ Automatic | ❌ Manual | ❌ Manual | 💰 | ⚠️ Manual |
| Open Source | ✅ | ✅ | ✅ | ❌ | ❌ |
DriftDB includes a comprehensive test suite with both Rust and Python tests organized into different categories.
# Run all tests (Rust + Python)
make test
# Run quick tests only (no slow/performance tests)
make test-quick
# Run specific test categories
make test-unit # Unit tests only
make test-integration # Integration tests
make test-sql # SQL compatibility tests
make test-python # All Python tests
The test suite is organized into the following categories:
tests/
├── unit/ # Fast, isolated unit tests
├── integration/ # Cross-component integration tests
├── sql/ # SQL standard compatibility tests
├── performance/ # Performance benchmarks
├── stress/ # Load and stress tests
├── legacy/ # Migrated from root directory
└── utils/ # Shared test utilities
# Run a specific test file
python tests/unit/test_basic_operations.py
# Run tests matching a pattern
pytest tests/ -k "constraint"
# Run with verbose output
python tests/run_all_tests.py --verbose
# Generate coverage report
make test-coverage
Tests should extend the DriftDBTestCase base class which provides:
Example test:
from tests.utils import DriftDBTestCase
class TestNewFeature(DriftDBTestCase):
def test_feature(self):
self.create_test_table()
self.assert_query_succeeds("INSERT INTO test_table ...")
result = self.execute_query("SELECT * FROM test_table")
self.assert_result_count(result, 1)
# Run tests
make test
# Run benchmarks
make bench
# Save benchmark baseline (for regression detection)
make bench-baseline
# Check for performance regressions (10% threshold)
make bench-check
# Format code
make fmt
# Run linter
make clippy
# Full CI checks
make ci
DriftDB includes automated benchmark regression detection:
# Save current performance as baseline
./scripts/benchmark_regression.sh --save-baseline
# Check for regressions (default 10% threshold)
./scripts/benchmark_regression.sh
# Check with custom threshold
./scripts/benchmark_regression.sh --threshold 5
The CI pipeline automatically checks for performance regressions on pull requests.
Measured on MacBook Air M3 (2024) - 8-core (4P+4E), 16GB unified memory, NVMe SSD:
Insert Operations:
Single insert: 4.3 ms
10 inserts: 35.5 ms (~3.5 ms each)
100 inserts: 300 ms (~3.0 ms each)
Query Operations:
SELECT 100 rows: 101 µs
SELECT 1000 rows: 644 µs
Full table scan: 719 µs (1000 rows)
Update/Delete Operations:
Single update: 6.7 ms
Single delete: 6.5 ms
Time Travel Queries:
Historical query: 131 µs (FOR SYSTEM_TIME AS OF @SEQ:N)
Throughput:
Run benchmarks yourself:
cargo bench --bench simple_benchmarksSee benchmarks/HARDWARE.md for hardware specs and benchmarks/baselines/ for detailed results.
MIT
DriftDB is currently in alpha stage with significant recent improvements but requires additional testing and validation.
Current Status:
FOR SYSTEM_TIME AS OF @SEQ:N and timestamp variants, through both the CLI/server SQL path and the read-only engine API (the engine's read-only path previously dropped timestamp variants — now resolves them correctly)=, !=, <, <=, >, >=) honored consistently across both engine read paths (predicate logic is shared via a single module — previously the read-only API silently treated everything as equality)Safe for:
NOT safe for:
| Component | Status | Development Ready |
|---|---|---|
| Core Storage Engine | 🟡 Alpha | For Testing |
| SQL Execution | 🟢 Working | Yes |
| Time Travel Queries | 🟢 Working | Yes |
| PostgreSQL Protocol | 🟢 Working | Yes |
| WAL & Crash Recovery | 🟡 Beta | Almost |
| ACID Transactions | 🟡 Beta | Almost |
| MVCC Isolation | 🟡 Beta | Almost |
| Event Sourcing | 🟢 Working | Yes |
| WHERE Clause Support | 🟢 Working | Yes |
| UPDATE/DELETE | 🟢 Working | Yes |
| Row-Level Security | 🟡 Beta | Almost |
| Query Optimizer | 🟡 Beta | Almost |
| Point-in-Time Recovery | 🟡 Beta | Almost |
| Replication Framework | 🟡 Beta | Almost |
| Schema Migrations | 🟡 Beta | Almost |
| Connection Pooling | 🔶 Alpha | No |
| Monitoring & Alerting | 🟡 Beta | Almost |
| Admin Tools | 🔶 Alpha | No |
184 commits
Rust
85.7%
Python
12.3%
DriftDB - An experimental append-only database with built-in time travel. Query any point in history, guaranteed data integrity, and immutable audit trails. Written in Rust.
See the codeExperimental PostgreSQL-Compatible Time-Travel Database (v0.9.1-alpha) - An ambitious temporal database project with advanced architectural designs for enterprise features. Query your data at any point in history using standard SQL.
⚠️ ALPHA SOFTWARE - NOT FOR PRODUCTION USE: This version contains experimental implementations of enterprise features. The codebase compiles cleanly with zero warnings and includes comprehensive CI with security auditing. Many advanced features remain as architectural designs requiring implementation.
Experience DriftDB's time-travel capabilities right now!
cd demo
./run-demo.sh
# Opens at http://localhost:8080
Or simply open demo/index.html in your browser - no installation required!
The interactive demo features:
# Start the PostgreSQL-compatible server
./target/release/driftdb-server --data-path ./data
# Connect with any PostgreSQL client
psql -h localhost -p 5433 -d driftdb
# Use standard SQL with time-travel
CREATE TABLE events (id INT PRIMARY KEY, data VARCHAR);
INSERT INTO events (id, data) VALUES (1, 'original');
UPDATE events SET data = 'modified' WHERE id = 1;
-- Query historical state!
SELECT * FROM events FOR SYSTEM_TIME AS OF @SEQ:1; -- Shows 'original'
SELECT * FROM events; -- Shows 'modified'
FOR SYSTEM_TIME AS OF for querying historical statesFOR SYSTEM_TIME AS OF: Query data at any point in time — accepts both ISO-8601 timestamps and DriftDB's @SEQ:N extension, and resolves correctly through both the CLI/server SQL path and the read-only engine API used by FK validationFOR SYSTEM_TIME ALL: Complete history of changesFOR SYSTEM_TIME BETWEEN and FOR SYSTEM_TIME FROM ... TO are parsed but not yet executable — they return a clear "not yet supported" error rather than silently dropping the clause. Implementing them needs a range-aware engine query variant; tracked as a follow-up.=, !=, <, <=, >, >=; the parallel path (used automatically for larger result sets) also handles LIKE, IN, NOT IN, and non-numeric ordering. Same query can return different rows depending on table size. Consolidating the two implementations is on the roadmap.The following features have been architecturally designed with varying levels of implementation:
# Quick start with Docker
git clone https://github.com/DavidLiedle/DriftDB.git
cd DriftDB
./scripts/docker-quickstart.sh
# Connect to DriftDB
psql -h localhost -p 5433 -d driftdb -U driftdb
# Set DRIFTDB_PASSWORD env var, or check server logs for generated password
# Clone and build from source
git clone https://github.com/DavidLiedle/DriftDB.git
cd DriftDB
make build
# Or install the binaries with cargo (these crates are not on crates.io;
# `driftdb-server` there is an unrelated project)
cargo install --path crates/driftdb-cli && cargo install --path crates/driftdb-server
# Run the full demo (creates sample data and runs queries)
make demo
# Demo includes:
# - Database initialization
# - Table creation with 10,000 sample orders
# - SELECT queries with WHERE clauses
# - Time-travel queries (FOR SYSTEM_TIME AS OF @SEQ:N)
# - Snapshot and compaction operations
DriftDB now includes a PostgreSQL wire protocol server, allowing you to connect with any PostgreSQL client:
# Start the server
./target/release/driftdb-server
# Connect with psql
psql -h 127.0.0.1 -p 5433 -d driftdb -U driftdb
# Connect with any PostgreSQL driver (set DRIFTDB_PASSWORD or check logs)
postgresql://driftdb:<password>@127.0.0.1:5433/driftdb
The server supports:
# Initialize database
driftdb init ./mydata
# Check version
driftdb --version
# Execute SQL directly
driftdb sql -d ./mydata -e "CREATE TABLE users (id INTEGER, email VARCHAR, status VARCHAR, PRIMARY KEY (id))"
# Or use interactive SQL file
driftdb sql -d ./mydata -f queries.sql
-- Create a temporal table
CREATE TABLE users (
id INTEGER,
email VARCHAR,
status VARCHAR,
created_at VARCHAR,
PRIMARY KEY (id)
);
-- Insert data
INSERT INTO users VALUES (1, 'alice@example.com', 'active', CURRENT_TIMESTAMP);
-- Standard SQL queries with WHERE clauses
SELECT * FROM users WHERE status = 'active';
SELECT * FROM users WHERE id > 100 AND status != 'deleted';
-- UPDATE with conditions
UPDATE users SET status = 'inactive' WHERE last_login < '2024-01-01';
-- DELETE with conditions (soft delete preserves history)
DELETE FROM users WHERE status = 'inactive' AND created_at < '2023-01-01';
-- Time travel query (SQL:2011)
SELECT * FROM users
FOR SYSTEM_TIME AS OF '2024-01-15T10:00:00Z'
WHERE id = 1;
-- Query all historical versions
SELECT * FROM users
FOR SYSTEM_TIME ALL
WHERE id = 1;
-- Advanced SQL Features (v0.6.0)
-- Column selection
SELECT name, email FROM users WHERE status = 'active';
-- Aggregation functions
SELECT COUNT(*) FROM users;
SELECT COUNT(email), AVG(age) FROM users WHERE status = 'active';
SELECT MIN(created_at), MAX(created_at) FROM users;
-- GROUP BY and aggregations
SELECT status, COUNT(*) FROM users GROUP BY status;
SELECT department, AVG(salary), MIN(salary), MAX(salary)
FROM employees GROUP BY department;
-- HAVING clause for group filtering
SELECT department, AVG(salary) FROM employees
GROUP BY department HAVING AVG(salary) > 50000;
-- ORDER BY and LIMIT
SELECT * FROM users ORDER BY created_at DESC LIMIT 10;
SELECT name, email FROM users WHERE status = 'active'
ORDER BY name ASC LIMIT 5;
-- Complex queries with all features
SELECT department, COUNT(*) as emp_count, AVG(salary) as avg_salary
FROM employees
WHERE hire_date >= '2023-01-01'
GROUP BY department
HAVING COUNT(*) >= 3
ORDER BY AVG(salary) DESC
LIMIT 5;
-- AS OF: Query at a specific point in time
SELECT * FROM orders
FOR SYSTEM_TIME AS OF '2024-01-15T10:30:00Z'
WHERE customer_id = 123;
-- AS OF @SEQ:N: DriftDB extension — query by sequence number
SELECT * FROM orders
FOR SYSTEM_TIME AS OF @SEQ:5000
WHERE customer_id = 123;
-- ALL: Complete history
SELECT * FROM audit_log
FOR SYSTEM_TIME ALL
WHERE action = 'DELETE';
FOR SYSTEM_TIME BETWEEN ... AND ... and FOR SYSTEM_TIME FROM ... TO ... are
parsed but not yet executable — they return a clear "not yet supported" error
rather than silently dropping the clause. Tracking implementation as a follow-up.
-- Create table with system versioning (standard SQL syntax)
CREATE TABLE orders (
id VARCHAR PRIMARY KEY,
status VARCHAR,
customer_id VARCHAR,
amount INTEGER
);
-- Insert data
INSERT INTO orders VALUES ('order1', 'pending', 'cust1', 100);
-- Update with conditions
UPDATE orders SET status = 'paid' WHERE id = 'order1';
-- Delete (soft delete preserves history for time-travel)
DELETE FROM orders WHERE id = 'order1';
-- Start a transaction
BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ;
-- Multiple operations in transaction
INSERT INTO orders VALUES ('order2', 'pending', 'cust2', 200);
UPDATE orders SET status = 'shipped' WHERE id = 'order1';
-- Commit or rollback
COMMIT;
-- or
ROLLBACK;
-- Query historical state by timestamp
SELECT * FROM orders FOR SYSTEM_TIME AS OF '2025-01-01T00:00:00Z' WHERE status = 'paid';
-- Query by sequence number
SELECT * FROM orders FOR SYSTEM_TIME AS OF @SEQ:1000 WHERE customer_id = 'cust1';
-- Show complete history of a record (CLI command)
driftdb drift -d ./data --table orders --key "order1"
-- Add a new column with default value
ALTER TABLE orders ADD COLUMN priority VARCHAR DEFAULT 'normal';
-- Add an index
CREATE INDEX idx_orders_created ON orders(created_at);
-- Drop a column
ALTER TABLE orders DROP COLUMN legacy_field;
# Create snapshot for performance
driftdb snapshot -d ./data --table orders
# Compact storage
driftdb compact -d ./data --table orders
# Check database integrity
driftdb doctor -d ./data
# Show table statistics
driftdb analyze -d ./data --table orders
data/
tables/<table>/
schema.yaml # Table schema definition
segments/ # Append-only event logs with CRC32
00000001.seg
00000002.seg
snapshots/ # Compressed materialized states
00000100.snap
indexes/ # Secondary B-tree indexes
status.idx
customer_id.idx
meta.json # Table metadata
wal/ # Write-ahead log for durability
wal.log
wal.log.1 # Rotated WAL files
migrations/ # Schema migrations
history.json
pending/
backups/ # Backup snapshots
[u32 length][u32 crc32][varint seq][u64 unix_ms][u8 event_type][msgpack payload]
-- "Prove we had user consent when we sent that email"
SELECT consent_status, consent_timestamp
FROM users
FOR SYSTEM_TIME AS OF '2024-01-15T14:30:00Z'
WHERE email = 'user@example.com';
-- "What was the state when the error occurred?"
SELECT * FROM shopping_carts
FOR SYSTEM_TIME AS OF '2024-01-15T09:45:00Z'
WHERE session_id = 'xyz-789';
-- "Show me how this metric changed over time"
SELECT DATE(SYSTEM_TIME_START) as date, COUNT(*) as daily_users
FROM users
FOR SYSTEM_TIME ALL
WHERE status = 'active'
GROUP BY DATE(SYSTEM_TIME_START);
-- "Restore accidentally deleted data"
INSERT INTO users
SELECT * FROM users
FOR SYSTEM_TIME AS OF '2024-01-15T08:00:00Z'
WHERE id NOT IN (SELECT id FROM users);
| Feature | DriftDB | PostgreSQL | MySQL | Oracle | SQL Server |
|---|---|---|---|---|---|
| SQL:2011 Temporal | ✅ Native | ⚠️ Extension | ❌ | 💰 Flashback | ⚠️ Complex |
| Storage Overhead | ✅ Low (events) | ❌ High | ❌ High | ❌ High | ❌ High |
| Query Past Data | ✅ Simple SQL | ❌ Complex | ❌ | 💰 Extra cost | ⚠️ Complex |
| Audit Trail | ✅ Automatic | ❌ Manual | ❌ Manual | 💰 | ⚠️ Manual |
| Open Source | ✅ | ✅ | ✅ | ❌ | ❌ |
DriftDB includes a comprehensive test suite with both Rust and Python tests organized into different categories.
# Run all tests (Rust + Python)
make test
# Run quick tests only (no slow/performance tests)
make test-quick
# Run specific test categories
make test-unit # Unit tests only
make test-integration # Integration tests
make test-sql # SQL compatibility tests
make test-python # All Python tests
The test suite is organized into the following categories:
tests/
├── unit/ # Fast, isolated unit tests
├── integration/ # Cross-component integration tests
├── sql/ # SQL standard compatibility tests
├── performance/ # Performance benchmarks
├── stress/ # Load and stress tests
├── legacy/ # Migrated from root directory
└── utils/ # Shared test utilities
# Run a specific test file
python tests/unit/test_basic_operations.py
# Run tests matching a pattern
pytest tests/ -k "constraint"
# Run with verbose output
python tests/run_all_tests.py --verbose
# Generate coverage report
make test-coverage
Tests should extend the DriftDBTestCase base class which provides:
Example test:
from tests.utils import DriftDBTestCase
class TestNewFeature(DriftDBTestCase):
def test_feature(self):
self.create_test_table()
self.assert_query_succeeds("INSERT INTO test_table ...")
result = self.execute_query("SELECT * FROM test_table")
self.assert_result_count(result, 1)
# Run tests
make test
# Run benchmarks
make bench
# Save benchmark baseline (for regression detection)
make bench-baseline
# Check for performance regressions (10% threshold)
make bench-check
# Format code
make fmt
# Run linter
make clippy
# Full CI checks
make ci
DriftDB includes automated benchmark regression detection:
# Save current performance as baseline
./scripts/benchmark_regression.sh --save-baseline
# Check for regressions (default 10% threshold)
./scripts/benchmark_regression.sh
# Check with custom threshold
./scripts/benchmark_regression.sh --threshold 5
The CI pipeline automatically checks for performance regressions on pull requests.
Measured on MacBook Air M3 (2024) - 8-core (4P+4E), 16GB unified memory, NVMe SSD:
Insert Operations:
Single insert: 4.3 ms
10 inserts: 35.5 ms (~3.5 ms each)
100 inserts: 300 ms (~3.0 ms each)
Query Operations:
SELECT 100 rows: 101 µs
SELECT 1000 rows: 644 µs
Full table scan: 719 µs (1000 rows)
Update/Delete Operations:
Single update: 6.7 ms
Single delete: 6.5 ms
Time Travel Queries:
Historical query: 131 µs (FOR SYSTEM_TIME AS OF @SEQ:N)
Throughput:
Run benchmarks yourself:
cargo bench --bench simple_benchmarksSee benchmarks/HARDWARE.md for hardware specs and benchmarks/baselines/ for detailed results.
MIT
DriftDB is currently in alpha stage with significant recent improvements but requires additional testing and validation.
Current Status:
FOR SYSTEM_TIME AS OF @SEQ:N and timestamp variants, through both the CLI/server SQL path and the read-only engine API (the engine's read-only path previously dropped timestamp variants — now resolves them correctly)=, !=, <, <=, >, >=) honored consistently across both engine read paths (predicate logic is shared via a single module — previously the read-only API silently treated everything as equality)Safe for:
NOT safe for:
| Component | Status | Development Ready |
|---|---|---|
| Core Storage Engine | 🟡 Alpha | For Testing |
| SQL Execution | 🟢 Working | Yes |
| Time Travel Queries | 🟢 Working | Yes |
| PostgreSQL Protocol | 🟢 Working | Yes |
| WAL & Crash Recovery | 🟡 Beta | Almost |
| ACID Transactions | 🟡 Beta | Almost |
| MVCC Isolation | 🟡 Beta | Almost |
| Event Sourcing | 🟢 Working | Yes |
| WHERE Clause Support | 🟢 Working | Yes |
| UPDATE/DELETE | 🟢 Working | Yes |
| Row-Level Security | 🟡 Beta | Almost |
| Query Optimizer | 🟡 Beta | Almost |
| Point-in-Time Recovery | 🟡 Beta | Almost |
| Replication Framework | 🟡 Beta | Almost |
| Schema Migrations | 🟡 Beta | Almost |
| Connection Pooling | 🔶 Alpha | No |
| Monitoring & Alerting | 🟡 Beta | Almost |
| Admin Tools | 🔶 Alpha | No |
184 commits
Rust
85.7%
Python
12.3%