MoteDB
AI-native embedded multimodal database for embodied intelligence. Columnar storage engine with ACID transactions, vector search, full-text search, and spatial indexing — in a single embedded library.
Status: pre-1.0. The Rust embedding API and storage engine are stable and heavily tested; the SQL surface and multi-language FFI are still evolving. See Supported SQL for the current feature set.
Quick Start
A minimal, runnable example (examples/hello_world.rs):
use ;
Run it with:
For the multimodal features (vector / full-text / spatial search), see
examples/crud.rs and the indexes overview.
Performance
Benchmark: 300K rows × 4 columns on Apple Silicon M-series vs SQLite 3.x WAL mode.
| Operation | MoteDB | SQLite | Winner |
|---|---|---|---|
| INSERT 300K | 125ms | 85ms | MoteDB (1.5x) |
| CREATE INDEX ×2 | 30ms | 90ms | MoteDB (3x) |
| WHERE = | 11ms | 14ms | MoteDB (1.3x) |
| ORDER BY LIMIT | 2.6ms | 6.5ms | MoteDB (2.5x) |
| COUNT/SUM/AVG WHERE | 2.8ms | 14ms | MoteDB (5x) |
| PK SELECT | <1μs | 1μs | MoteDB |
| LIKE | 13ms | 10ms | SQLite (1.3x) |
| DISTINCT | 8.5ms | 4.6ms | SQLite (1.9x) |
| SELECT * | 27ms | 9.7ms | SQLite (2.8x) |
Memory: 257 B/row (vs SQLite 369 B/row — 30% less)
Architecture
┌─────────────────────────────────────────────────────┐
│ MoteDB │
├──────────┬──────────┬──────────┬───────────────────┤
│ SQL │ Vector │ Text │ Spatial │
│ Parser │ DiskANN │ FTS │ i-Octree │
├──────────┴──────────┴──────────┴───────────────────┤
│ Columnar Storage Engine │
│ ┌─────────┐ ┌──────────┐ ┌────────────────────┐ │
│ │ WAL │→ │ Columnar │→ │ Columnar SSTable │ │
│ │ (fsync) │ │ Buffer │ │ (mmap + Snappy) │ │
│ └─────────┘ └──────────┘ └────────────────────┘ │
├─────────────────────────────────────────────────────┤
│ MVCC Transaction │ Snapshot Isolation │ Conflict │
└─────────────────────────────────────────────────────┘
- Storage: Columnar SSTable with Snappy compression, mmap zero-copy access
- Write Path: WAL (durability) → columnar buffer → auto-finalize → SSTable
- Read Path: SelectColumnar (zero-materialization), typed array access, predicate pushdown
- Transactions: VersionStore MVCC with snapshot isolation and conflict detection
Logging
MoteDB emits lifecycle and durability events (WAL flush, checkpoint, background
thread errors) through the standard log facade. The
library installs no logger itself — your application chooses one (e.g.
env_logger, tracing, slog) and controls verbosity:
RUST_LOG=motedb=info RUST_LOG=motedb=warn RUST_LOG=motedb=debug
With no logger installed, all logging compiles to a no-op (zero runtime cost).
See examples/logging.rs for a runnable demo.
Features
Multimodal
| Modality | Index | Query |
|---|---|---|
| Tabular | Column Value (B-tree) | WHERE, ORDER BY, GROUP BY |
| Vector | DiskANN (Vamana graph) | ORDER BY col <-> query LIMIT k |
| Text | FTS (Inverted Index) | WHERE MATCH(col) AGAINST('query') |
| Spatial | i-Octree (3D) | ST_DISTANCE, KNN, radius search |
Embedded Optimized
- Low memory: 257 B/row (30% less than SQLite)
- Zero-copy reads: mmap with on-demand page loading
- Fast writes: Zero-encode columnar INSERT (2.4M rows/s)
- Small disk: Snappy compression (~1.8x, 68 B/row)
- No daemon: Single library, embedded directly
ACID
- Atomic: WAL-based crash recovery
- Consistent: PK uniqueness, NOT NULL, type coercion
- Isolated: MVCC snapshot isolation
- Durable: WAL fsync + auto-finalize
Installation
Or in Cargo.toml:
[]
= "0.5"
For minimal edge builds (no tokenizer, no parallelism), disable default features:
[]
= { = "0.5", = false, = ["jemalloc"] }
Configuration
Pick a preset that matches your device, or start from one and override fields:
use ;
// Edge device (low memory, periodic fsync, single write partition)
let config = for_edge;
// Robotics (fast sensor ingestion, vector support)
let config = for_robotics;
// Embodied AI (vision-language models, real-time control loops)
let config = for_embodied;
let db = create_with_config?;
See docs/ for the full configuration reference and per-field docs.
SQL Support
Supported: CREATE TABLE / CREATE INDEX (column, vector, text, spatial),
DROP TABLE [IF EXISTS], INSERT, UPDATE, DELETE, SELECT with
WHERE, JOIN (INNER/LEFT/RIGHT/FULL), GROUP BY, ORDER BY, LIMIT/OFFSET,
DISTINCT, aggregates (COUNT, SUM, MIN, MAX), and transactions
(BEGIN/COMMIT/ROLLBACK).
Not yet supported: WITH/CTE/recursive queries, COUNT(DISTINCT ...),
multi-column GROUP BY, DECIMAL/DATE/BLOB types, and full-text search
predicate functions (the FTS index builds, but MATCH ... AGAINST is incomplete).
Documentation
Full guides live in docs/:
- Quick start · Installation & config · SQL operations
- Batch operations · Transactions
- Indexes: overview · column · vector · text · spatial · timestamp
- Performance tuning · Data types · API reference · Best practices · FAQ
API docs: https://docs.rs/motedb
License
MIT — see LICENSE.