Stoolap is a feature-rich embedded SQL database built in pure Rust. It targets low-latency transactional workloads and real-time analytical queries, with modern SQL features and no external server process.
Why Stoolap?
Stoolap is designed around practical embedded database needs:
- ACID + MVCC: concurrent reads and writes with transaction isolation
- Cost-based optimization: statistics-aware planning with adaptive execution
- Rich SQL surface: joins, subqueries, CTEs, window functions, advanced aggregations
- Multiple index types: B-tree, Hash, Bitmap, multi-column, and HNSW for vectors
- Pure Rust runtime: memory-safe implementation, no C/C++ dependency chain
Feature Snapshot
| Feature | Stoolap | SQLite | DuckDB | PostgreSQL |
|---|---|---|---|---|
| AS OF Time-Travel Queries | ✅ | ❌ | ❌ | ❌* |
| MVCC Transactions | ✅ | ❌ | ✅ | ✅ |
| Cost-Based Optimizer | ✅ | ❌ | ✅ | ✅ |
| Adaptive Query Execution | ✅ | ❌ | ❌ | ❌ |
| Semantic Query Caching | ✅ | ❌ | ❌ | ❌ |
| Parallel Query Execution | ✅ | ❌ | ✅ | ✅ |
| Native Vector / HNSW Search | ✅ | ❌ | ❌ | ❌ |
| Pure Rust (Memory Safe) | ✅ | ❌ | ❌ | ❌ |
*PostgreSQL typically needs extensions for temporal query workflows.
Quick Start
Installation
[]
= "0.3"
Build from source:
Rust API
use Database;
CLI
# Interactive REPL
# Execute a single query
# Persistent database
Stoolap Studio
Stoolap Studio is a web-based database management interface with a SQL editor, schema browser, interactive data grid, vector search, and backup/restore.
&& &&
Core SQL Capabilities
Transactions and Time-Travel
BEGIN;
UPDATE accounts SET balance = balance - 100 WHERE id = 1;
UPDATE accounts SET balance = balance + 100 WHERE id = 2;
COMMIT;
SELECT * FROM accounts AS OF TIMESTAMP '2024-01-15 10:30:00';
SELECT * FROM inventory AS OF TRANSACTION 1234;
Cost-Based Query Optimizer
ANALYZE orders;
ANALYZE customers;
EXPLAIN SELECT * FROM orders WHERE customer_id = 100;
EXPLAIN ANALYZE
SELECT o.*, c.name
FROM orders o
JOIN customers c ON o.customer_id = c.id
WHERE c.country = 'US';
Indexing
-- Auto-selected by data type
(created_at); -- B-tree
(email); -- Hash
(is_active) USING BITMAP;
-- Multi-column
(user_id, event_type);
Advanced SQL
WITH ranked AS (
SELECT
customer_id,
amount,
ROW_NUMBER OVER (PARTITION BY customer_id ORDER BY amount DESC) AS rn
FROM orders
)
SELECT * FROM ranked WHERE rn = 1;
Vector and Semantic Search
Stoolap supports native vectors via VECTOR(N) and approximate nearest-neighbor search with HNSW.
(
id INTEGER PRIMARY KEY,
content TEXT,
embedding VECTOR(384)
);
(embedding)
USING HNSW WITH (metric = 'cosine', m = 32, ef_construction = 400, ef_search = 128);
SELECT id, content,
VEC_DISTANCE_COSINE(embedding, '[0.1, 0.2, ...]') AS dist
FROM embeddings
ORDER BY dist
LIMIT 10;
For built-in semantic text embeddings, enable the semantic feature:
[]
= { = "0.3", = ["semantic"] }
SELECT EMBED('How to reset my password');
See Vector Search and Semantic Search docs for full workflows.
Storage and Durability
- Write-Ahead Logging (WAL)
- Periodic snapshots
- Crash recovery and index persistence
- Configurable sync and compression behavior
Performance
Detailed benchmark results are in BENCHMARKS.md.
Benchmark figures are point-in-time and workload-dependent. Validate on your own hardware, data distribution, and query patterns.
Documentation
- Installation: https://stoolap.io/docs/getting-started/installation/
- SQL commands: https://stoolap.io/docs/sql-commands/sql-commands/
- Data types: https://stoolap.io/docs/data-types/data-types/
- Functions: https://stoolap.io/docs/functions/sql-functions-reference/
- Architecture: https://stoolap.io/docs/architecture/architecture/
- Drivers: Node.js | Python | PHP | WASM | C
Development
Contributing
See CONTRIBUTING.md.
License
Apache License 2.0. See LICENSE.