โก ULTSQL - Converged Multimodal Database Engine
๐ฆ Package: ultsql | pub.dev
๐ Official Website & Docs: ultsql.tech | Interactive Docs | Empirical Benchmarks | Privacy Policy | Delete Account
โจ App & Cloud Database Wishlist: Sign up for the Wishlist
๐ฌ ULTSQL Cloud / Managed Service: Join the Waitlist
โก Feature Matrix & Customization Guide: FEATURES.md
ULTSQL is a 5-in-1 converged multimodal database engine whose core storage, execution engine, and networking are written in 100% pure Dart with zero native C/C++ dependencies. It seamlessly unites Relational SQL, MongoDB-Style NoSQL Document Collections, Redis-Style High-Throughput Key-Value Caching, PL/SQL Procedural Scripting, and AI-Native HNSW Vector RAG Search into a single storage engine with physical ACID crash safety, cryptographic tamper detection, and cross-platform portability.
๐ฆ SDK Availability Note:
package:ultsqlon pub.dev includes embedded Flutter UI inspection tools alongside the database engine. For headless Dart backend servers and non-Flutter environments, use the compiled native binary (install.sh/install.ps1), run via Docker, or connect over PostgreSQL Wire protocol (port 5432).
โก 5-Line Quickstart
import 'package:ultsql/ultsql.dart';
void main() async {
final db = Database('./app_data.db');
await db.init();
final interpreter = Interpreter(db);
await interpreter.executeScript('''
CREATE TABLE users (id INT PRIMARY KEY, name TEXT, embedding VECTOR);
INSERT INTO users VALUES (1, 'Alice', '[0.12, 0.85, -0.44]');
SELECT * FROM users;
''');
}
๐ก Demo: Run
dart run bin/ultsql_cli.dartorflutter runfor an interactive SQL studio console.
๐ Universal Installation for All Languages & Operating Systems
ULTSQL can be accessed by any developer, programming language, or operating system:
graph TD
subgraph "Your Application (Any System)"
Dart[๐ Flutter & Dart]
Py[๐ Python]
Node[๐ข Node.js / TS]
Go[๐น Go]
Rust[๐ฆ Rust]
CPP[๐ป C / C++]
JVM[โ Java / Kotlin / C#]
CLI[๐ฅ๏ธ Windows / Mac / Linux CLI]
Docker[๐ณ Docker Container]
end
subgraph "Package Registries & Connectors"
Pub[Pub.dev: package:ultsql]
PyPI[PyPI: pip install ultsql]
NPM[NPM: npm install ultsql]
GoMod[Go Modules: bindings/go]
Cargo[Crates.io: ultsql]
PGWire[PGWire: Port 5432 / libpq / JDBC / Npgsql]
Releases[GitHub Releases: Standalone Binaries]
Hub[Docker Hub: docker run]
end
Dart --> Pub
Py --> PyPI
Node --> NPM
Go --> GoMod
Rust --> Cargo
CPP --> PGWire
JVM --> PGWire
CLI --> Releases
Docker --> Hub
1. ๐ Flutter & Dart Developers (Native In-Process Engine)
100% Pure Dart! Zero external daemons or C/C++ compiler toolchains. Runs directly inside your application process across iOS, Android, macOS, Windows, Linux, and Web:
dart pub add ultsql
# or for Flutter apps:
flutter pub add ultsql
import 'package:ultsql/ultsql.dart';
void main() async {
// 1. Open persistent disk database (or ':memory:' for RAM)
final db = Database('./app.db');
await db.init();
final it = Interpreter(db);
// 2. Execute SQL DDL & Multi-row batch
await it.executeScript('''
CREATE TABLE users (id INT PRIMARY KEY, name TEXT, score DOUBLE);
INSERT INTO users VALUES (1, 'Alice', 98.5);
INSERT INTO users VALUES (2, 'Bob', 91.2);
''');
// 3. Query records
final res = await it.executeScript("SELECT * FROM users WHERE score >= 90;");
for (final row in res.rows) {
print('User: ${row[1]} (Score: ${row[2]})');
}
// 4. Clean shutdown (flushes cache & WAL)
await db.close();
}
2. ๐ Python Developers (Client SDK & Opt-in Local Helper Engine)
No Dart or Flutter required! Ships pre-compiled native platform wheels via pip.
Python Application โ UltSQL Client SDK โ local UltSQL engine (127.0.0.1) โ database file
Two operating modes:
- Local Mode (Opt-in
auto_start=True): Automatically starts a loopback helper engine on a free port (127.0.0.1), reuses running processes for the same database file, and terminates cleanly upon exit. - Client Mode: Connects directly to an existing local or remote server (
auto_start=False).
pip install ultsql
import ultsql
# Local mode (auto-starts engine on 127.0.0.1 with random port)
db = ultsql.open("app.ultsql", auto_start=True)
# Inspect health & process
print(db.status()) # {'status': 'online', 'host': '127.0.0.1', 'port': 54321, ...}
# 1. Execute SQL DDL / Queries
db.sql("CREATE TABLE users (id INT PRIMARY KEY, name TEXT, score DOUBLE);")
# 2. High-speed batch insert
db.insert_batch("users", [
{"id": 1, "name": "Alice", "score": 98.5},
{"id": 2, "name": "Bob", "score": 91.2},
])
# 3. Query records
users = db.query("users")
print("User rows:", users["rows"])
# 4. Clean shutdown (also auto-cleaned via atexit)
db.close()
To connect to an already-running server instead: db = ultsql.UltSQLClient("http://127.0.0.1:8080")
To start an explicit dev server: ultsql dev --db ./app.ultsql
3. ๐ข Node.js & TypeScript Developers (Client SDK & Opt-in Local Helper Engine)
No Dart or Flutter required! Automatically downloads the matching platform package (@ultsql/win32-x64, @ultsql/linux-x64, @ultsql/darwin-arm64).
Node.js Application โ UltSQL Client SDK โ local UltSQL engine (127.0.0.1) โ database file
Two operating modes:
- Local Mode (Opt-in
auto_start: true): Automatically starts a loopback helper engine on a free port (127.0.0.1), reuses running processes for the same database file, and terminates cleanly upon exit. - Client Mode: Connects directly to an existing local or remote server (
auto_start: false).
npm install ultsql
const { UltSQL, UltSQLClient } = require('ultsql');
async function main() {
// Local mode (auto-starts engine on 127.0.0.1 with dynamic port)
const db = await UltSQL.open('app.ultsql', { auto_start: true });
// Inspect health & process
const status = await db.status();
console.log('Status:', status);
// 1. Execute SQL DDL
await db.sql('CREATE TABLE users (id INT PRIMARY KEY, name TEXT, score DOUBLE);');
// 2. High-throughput batch ingestion
await db.insertBatch('users', [
{ id: 1, name: 'Alice', score: 98.5 },
{ id: 2, name: 'Bob', score: 91.2 }
]);
// 3. Query records
const result = await db.query('users');
console.log('Users:', result.rows);
// 4. Clean shutdown (also auto-cleaned on process exit)
db.close();
}
main();
To connect to an already-running server instead: const client = new UltSQLClient('http://127.0.0.1:8080');
To start an explicit dev server: ultsql dev --db ./app.ultsql
4. ๐น Go Developers (Auto-Start Bundled Engine + REST)
No Dart or Flutter required! Starts a small bundled engine process automatically on a free port:
go get github.com/ompatel3158/ULTSQL/bindings/go
package main
import (
"context"
"fmt"
"log"
"github.com/ompatel3158/ULTSQL/bindings/go"
)
func main() {
// Embedded mode: starts a small bundled engine process automatically
db, err := ultsql.Open("app.db")
if err != nil {
log.Fatalf("Failed to open UltSQL: %v", err)
}
defer db.Close()
ctx := context.Background()
// 1. High-speed batch ingestion
_, err = db.InsertBatch(ctx, "users", []map[string]interface{}{
{"id": 1, "name": "Alice", "score": 98.5},
{"id": 2, "name": "Bob", "score": 91.2},
})
if err != nil {
log.Fatalf("InsertBatch failed: %v", err)
}
// 2. Query records
res, err := db.Query(ctx, "SELECT * FROM users WHERE score >= 90.0;")
if err != nil {
log.Fatalf("Query failed: %v", err)
}
fmt.Printf("Returned %d rows in %.2f ms\n", len(res.Rows), res.ExecutionTimeMs)
}
To connect to a remote server instead: client := ultsql.NewClient("http://remote-server:8080")
Or connect using standard database/sql with github.com/lib/pq:
db, err := sql.Open("postgres", "postgres://admin:admin@localhost:5432/ultsql_db?sslmode=disable")
5. ๐ฆ Rust Developers (Auto-Start Bundled Engine + REST)
No Dart or Flutter required! Starts a small bundled engine process automatically on a free port:
Add to Cargo.toml:
[dependencies]
ultsql = "1.0.28"
tokio = { version = "1.0", features = ["full"] }
serde_json = "1.0"
use ultsql::UltSqlClient;
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Embedded mode: starts a small bundled engine process automatically
let db = UltSqlClient::open("app.db").await?;
// 1. High-speed batch ingestion
db.insert_batch("users", &[
json!({"id": 1, "name": "Alice", "score": 98.5}),
json!({"id": 2, "name": "Bob", "score": 91.2}),
]).await?;
// 2. Query records
let res = db.query("SELECT * FROM users WHERE score >= 90.0;").await?;
println!("Columns: {:?}", res.columns);
println!("Rows: {:?}", res.rows);
// Auto-terminated on drop or explicit db.close()
Ok(())
}
To connect to a remote server instead: let client = UltSqlClient::new("http://remote-server:8080");
Or connect asynchronously via tokio-postgres or sqlx on port 5432.
6. ๐ป C & C++ Developers (libpq / libpqxx & REST API)
Connect natively using standard PostgreSQL C/C++ client libraries or HTTP REST:
#include <pqxx/pqxx>
#include <iostream>
int main() {
try {
pqxx::connection conn("postgresql://admin:admin@localhost:5432/ultsql_db");
pqxx::work txn(conn);
pqxx::result res = txn.exec("SELECT id, name, score FROM users WHERE score >= 90.0;");
for (auto row : res) {
std::cout << row["name"].c_str() << ": " << row["score"].as<double>() << "\n";
}
} catch (const std::exception &e) {
std::cerr << "Error: " << e.what() << "\n";
}
return 0;
}
7. โ Java, Kotlin & C# (.NET) Developers (JDBC & Npgsql)
Connect with standard enterprise database drivers over the PostgreSQL v3 wire protocol:
-
Java / Kotlin (JDBC):
Connection conn = DriverManager.getConnection( "jdbc:postgresql://localhost:5432/ultsql_db", "admin", "admin" ); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM users;"); -
C# / .NET (Npgsql):
await using var dataSource = NpgsqlDataSource.Create( "Host=localhost;Port=5432;Database=ultsql_db;Username=admin;Password=admin" ); await using var cmd = dataSource.CreateCommand("SELECT * FROM users"); await using var reader = await cmd.ExecuteReaderAsync();
8. ๐ฅ๏ธ 1-Line Standalone CLI Installers (Windows, macOS, Linux)
Zero Dependencies! Automatically downloads the native binary for your architecture and adds ultsql to system PATH:
- Windows (PowerShell):
iwr -useb https://raw.githubusercontent.com/ompatel3158/ULTSQL/main/install.ps1 | iex - Linux & macOS (Bash):
curl -fsSL https://raw.githubusercontent.com/ompatel3158/ULTSQL/main/install.sh | bash
Once installed, use ultsql anywhere on your machine:
ultsql app.db # Interactive REPL with auto-completion
ultsql bench 1000000 # Live 1M-row disk ingestion benchmark
ultsql app.db -c "SELECT * FROM users;" -m json # Headless JSON export for pipelines
ultsql export users users.csv # Streaming table export
ultsql import data.json users # Zero-allocation batch import
ultsql dev --db ./app.ultsql # Local dev server on 127.0.0.1:8080 with live logs
ultsql serve --port=8080 --pgwire=5432 --db=./my_db # Combined REST API & PostgreSQL wire daemon
9. ๐ณ Docker Container (Cloud & Servers)
docker run -d -p 8080:8080 -p 5432:5432 -v ./data:/db ompatel3158/ultsql:latest serve --port 8080 --pgwire 5432 --db /db
10. ๐ PostgreSQL Wire Protocol (psql, GUI Clients & BI Tools)
Connect directly from standard database management tools (DBeaver, TablePlus, Grafana, psql):
# Start standalone PGWire daemon on port 5432
ultsql pgwire --port=5432 --db=./my_db
# Connect with psql
psql "host=localhost port=5432 user=admin dbname=ultsql_db"
๐ Standalone Engine Metrics
| Capability / Benchmark | UltSQL Performance | Feature Status |
|---|---|---|
Durable Disk Ingestion Pipeline (executeBatchSync) |
2,087,683 rows/sec (2.08M rows/sec) | โก Real NVMe Physical Storage, Slotted Pages, Sequential WAL Flush, Zero Data Loss Verified |
Converged NoSQL Point Read Latency (findOne) |
3.61 ยตs (Direct B+ Tree + Micro-Cache) | โก 32.8x Acceleration, Crushes MongoDB (182.4 ยตs) & SQLite (118.6 ยตs) |
In-Memory KV Cache Read (kv.get) |
1,282,051 ops/sec (1.28M ops/sec) | ๐ Zero-Latency Pure Dart In-Memory Hot Store with TTL & Disk Persistence |
| Enterprise Cybersecurity & Tamper Detection | AES-256-CTR + HMAC-SHA256 | ๐ก๏ธ Active Bit-Tamper Trapping, Dual Envelopes (inPage/companion), PBKDF2 (10,000 rounds), Memory Zeroization |
| Direct Slotted-Page Vector Ingestion | 5,580,357 rows/sec (5.58M rows/sec) | โก Vectorized Slotted-Page Binary Serialization Bypassing SQL AST |
| Bulk Ingest (50K Batch on NVMe) | 3,451,847 rows/sec (3.45M rows/sec) | ๐พ Multi-Row Batch with Physical WAL Commit Flush (2.02x Faster Than SQLite) |
Public Batch Ingestion API (insertBatch) |
4,071,661 rows/sec (4.07M rows/sec) | โก Batch Prepared Execution with Automatic Indexing & Catalog Stats |
| PL/SQL Transaction Loop Ingestion | 212,450 rows/sec | ๐ In-Engine JIT Loop with B+ Tree Indexing & WAL Logging |
| Single-Tx Auto-Commit Transaction Pipeline | 563,380 tx/sec | ๐ Sequential ARIES Write-Ahead Log Group-Commit Flush |
| B+ Tree Index Build (50K Rows) | 2.739 ms | ๐ High-Speed Bulk B+ Tree Indexing (insertSortedBatchSync) |
| 768-Dim HNSW AI Vector RAG | 5.0 ms (High-Recall ANN, 100% Recall@10, 56.6K vec/s) | ๐ง Native AI Embedded Vector Engine |
| Network TCP Wire Protocol Server | Port 5432 (PostgreSQL v3) + TLS 1.3 | ๐ Dynamic TLS Handshake, Full Driver Compatibility (psql, psycopg2, JDBC) |
| WAL Crash Recovery & Checkpoints | CRC32 Checked Automatic Replay | ๐ก๏ธ Durable ACID Crash Safety (recoverSync) |
| Offline CRDT State Synchronization | In-Memory LWW-Element-Set | ๐ฒ Conflict-Free Peer State Merging (P2pSyncNode) |
| Universal Direct File SQL Queries | CSV, JSON, LOG Files | ๐ Zero-ETL Direct Queries |
| Transparent Database Encryption | AES-256-CTR (Pure Dart) | ๐ Opt-in Disk Encryption via Passphrase |
๐๏ธ System Architecture
UltSQL uses a multi-layered Volcano-iterator query engine over custom slotted-page disk/memory tables, LRU page caching, B+ Trees, and HNSW vector graphs:
graph TD
UI[Flutter IDE Console / Client App] -->|SQL / PL-SQL / NL Prompt| Interpreter[Interpreter Engine]
Interpreter -->|Natural Language AI| NlEngine[NL-to-SQL AI Compiler]
Interpreter -->|Lexical Analysis| Lexer[Hand-Written Lexer]
Lexer -->|Tokens| Parser[Hand-Written Parser]
Parser -->|AST Tree| QueryPlanner[Optimizing Query Planner]
QueryPlanner -->|Physical Execution Plan| VolcanoEngine[Volcano Iterator Execution Engine]
VolcanoEngine -->|Page Operations| PageCache[LRU Page Cache Buffer]
PageCache -->|CRC32 Page Verification| Pager[Slotted Page Pager]
Pager -->|Storage Engines| StorageAdapters
subgraph StorageAdapters[Converters & Adapters]
MemoryStore[MemoryStore: Fast Ephemeral In-Memory Store]
RowStore[.db: Row-Oriented Slotted Pages]
ColumnStore[.col_*: Columnar Parquet Store]
BTreeIndex[.idx: B+ Tree Indexes]
HnswIndex[.hnsw: HNSW Vector Graph]
FileAdapter[Universal CSV / JSON / LOG Adapter]
end
VolcanoEngine -->|Network Server| PgWireServer[TCP Wire Protocol Server]
VolcanoEngine -->|CRDT State| P2pNode[LWW CRDT Sync Node]
๐ Table of Contents
- ๐ Standalone Engine Metrics
- ๐๏ธ System Architecture
- ๐ The 17 Signature Innovations
- โ๏ธ Storage Modes: Switchable Performance
- ๐ ๏ธ SQL & PL/SQL Feature Guide
- ๐ Converged NoSQL Document Store & Redis-Style KV Engine
- ๐ง AI-Native HNSW Vector RAG Search
- ๐ Network TCP Wire Protocol Server with TLS 1.3
- ๐ก๏ธ WAL CRC32 Crash Recovery & Auto-Indexing
- ๐ฒ In-Memory LWW CRDT State Merging
- ๐ Direct File SQL Queries (CSV / JSON / LOG)
- ๐ Deterministic Obfuscation (XOR Fast Matching)
- ๐ก๏ธ Enterprise Cybersecurity & Active Tamper Detection
- โก 2.08M Rows/Sec Durable NVMe Ingestion Pipeline
- ๐ฅ๏ธ Next-Gen Interactive CLI & Tooling
- ๐ค Model Context Protocol (MCP) Server & AI Agent Skills
- ๐ Standalone Engine Performance & Head-to-Head Benchmarks
- ๐ Getting Started & Installation
- ๐ License
๐ The 17 Signature Innovations
UltSQL introduces 17 signature database innovations engineered specifically for high-throughput client and cloud workloads:
- โก 2.08M Rows/Sec Durable NVMe Ingestion Pipeline: Ingests 2,087,683 rows/sec on physical disk using slotted-page serialization, batch prepared execution, and chunked sequential WAL commit with zero data loss.
- ๐ก๏ธ Enterprise Cybersecurity & Active Tamper Detection: Combines pure-Dart AES-256-CTR encryption with HMAC-SHA256 authenticated envelopes (
inPage4064-byte payload orcompanionfile), PBKDF2-HMAC-SHA256 (10,000 rounds), cross-page swap prevention, cryptographic memory zeroization, and TLS 1.3 network transport. - ๐ Fast B+ Tree Bulk Indexing:
insertSortedBatchSyncindexes 50,000 rows in 2.739 ms (2.99x faster than SQLite 3). - ๐ง Native HNSW Vector RAG Graph: Cosine & Euclidean similarity search over 768-dim embeddings in 5.0 ms with 100% recall.
- ๐ Network TCP Wire Protocol Server with TLS 1.3: Full PostgreSQL v3 wire protocol server with parameter status, backend key negotiation, and dynamic SSL/TLS socket upgrade.
- ๐ก๏ธ WAL CRC32 Crash Recovery Engine: Detects torn writes and crashes with CRC32 checksums, replaying committed transactions and restoring catalog state on startup.
- ๐ค Autonomous Telemetry Auto-Indexer: Monitors query scan frequencies and automatically provisions B+ Tree indexes.
- ๐ Universal Direct File SQL Adapter: Runs live SQL queries over standard
.csv,.json, and.logfiles without importing into tables. - ๐ฃ๏ธ AI Natural Language to SQL Compiler: Translates natural language prompts into executable SQL statements.
- ๐ Searchable Ciphertext (XOR Equality Search): Performs fast equality searches over deterministic repeating-key XOR-encrypted ciphertext.
- ๐ฒ In-Memory LWW CRDT State Merging: Last-Write-Wins element state merging for multi-device sync workflows (
P2pSyncNode). - ๐ฆ Zero-Allocation
RowMapTuple Wrapper: Replaces DartMapinstantiations with zero-allocation array index views. - โก JIT Compiled Expressions: Compiles SQL
WHEREconditions into native Dart closure delegates. - ๐ Auto-Optimized Columnar Parquet Store: Automatically converts tables with
VECTORor analytical data into columnar layout. - ๐ MVCC Multi-Version Concurrency Control: Provides lock-free readers, repeatable read isolation, and OS-level multi-process file locking.
- โก Dual Storage Modes: Switch between sub-millisecond in-memory processing and crash-safe NVMe persistence with a single argument.
- ๐ Converged Multi-Model NoSQL & Redis-Style KV: Combines MongoDB-style schema-less document collections with dotted-path filtering and atomic mutations (
$set,$inc,$push,$pull) alongside a Redis-style TTL key-value engine, queryable directly via SQL bridges (SELECT * FROM collection('users')).
โ๏ธ Storage Modes: Switchable Performance
Switch between in-memory speed and durable disk storage with a single line of code:
1. โก In-Memory Storage Mode (5,580,357 rows/sec slotted-page batch, sub-microsecond point lookups)
For high-frequency streaming, real-time AI vector search, and temporary session caches:
final db = Database(':memory:');
await db.init();
2. ๐พ Durable Disk Storage Mode (3,451,847 rows/sec 50K batch, 2,087,683 rows/sec 1M rows NVMe WAL)
For persistent local application data with ACID crash safety and automatic WAL crash recovery:
final db = Database('/path/to/app_data/my_database');
await db.init();
3. ๐ Hybrid Ingest & Snapshot
final prep = db.prepare("INSERT INTO users VALUES (?, ?, ?);");
prep.executeBatchSync(batchRows);
await db.flushWalSync(); // Flush WAL snapshot to disk
4. โก High-Speed Public Batch Ingestion (insertBatch & insertBatchRecords)
Ingest hundreds of thousands of records per second with automatic slotted-page layout, B+ Tree indexing, and instant SQL queryability:
// Option A: Batch insert rows with column mapping
await engine.insertBatch('users', [
[1, 'Alice', 98.5],
[2, 'Bob', 91.2],
], columns: ['id', 'name', 'score']);
// Option B: Batch insert structured records (JSON maps)
await engine.insertBatchRecords('users', [
{'id': 1, 'name': 'Alice', 'score': 98.5},
{'id': 2, 'name': 'Bob', 'score': 91.2},
]);
๐ ๏ธ SQL & PL/SQL Feature Guide
Data Definition Language (DDL) & Metadata Inspection
-- Enhanced DDL with IF NOT EXISTS / IF EXISTS and TRUNCATE
CREATE TABLE IF NOT EXISTS users (
id UUID PRIMARY KEY,
name VARCHAR(250),
active BOOL DEFAULT true,
created_at TIMESTAMP,
balance DECIMAL,
payload BLOB,
metadata JSON,
embedding VECTOR
);
-- DDL & Catalog Inspection Commands
DESCRIBE users;
SHOW COLUMNS FROM users;
SHOW SCHEMAS;
PRAGMA table_info('users');
-- Query System Catalog Views
SELECT table_name, column_name, data_type
FROM information_schema.columns
WHERE table_name = 'users';
Data Manipulation, UPSERT & Series Generation
-- Series Generator
SELECT * FROM generate_series(1, 10, 2);
-- Standard DML & Multi-Row Inserts
INSERT INTO users VALUES ('a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11', 'Alice', true, NOW(), 1500.50, NULL, '{"role": "admin"}', '[0.12, 0.85]');
-- UPSERT (ON CONFLICT DO UPDATE / DO NOTHING) & REPLACE INTO
INSERT INTO users (id, name, balance) VALUES ('a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11', 'Alice', 2000.00)
ON CONFLICT (id) DO UPDATE SET balance = 2000.00;
INSERT INTO users (id, name) VALUES ('a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11', 'Alice')
ON CONFLICT DO NOTHING;
REPLACE INTO users VALUES ('a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11', 'Alice Updated', true, NOW(), 2500.00, NULL, '{}', '[0.1, 0.2]');
Casting, Regex & Developer Functions
-- ANSI CAST & PostgreSQL :: Typecasting
SELECT balance::TEXT, CAST(active AS INT), name::VARCHAR FROM users;
-- ILIKE (Case-Insensitive) & Regex Matching (~ operator and REGEXP_LIKE)
SELECT * FROM users WHERE name ILIKE 'alice%' OR email ~ '^[a-z]+@';
SELECT REGEXP_LIKE('support@ultsql.tech', '^[a-z]+@[a-z]+\.[a-z]+$');
-- Developer Scalar & Math Functions
SELECT
COALESCE(NULL, 'default_val'),
NULLIF(10, 10),
GREATEST(10, 50, 20),
LEAST(10, 50, 20),
CONCAT_WS('-', '2026', '08', '06'),
TYPEOF(100),
GEN_RANDOM_UUID(),
ABS(-42), ROUND(3.14159, 2), CEIL(4.2), FLOOR(4.8), POW(2, 3), SQRT(16),
REPLACE('hello world', 'world', 'ultsql'), SPLIT_PART('a.b.c', '.', 2), INITCAP('hello world'),
DATE_ADD('2026-08-06', 10), DATE_SUB('2026-08-06', 5), EXTRACT('year', NOW()),
VERSION();
-- UPSERT & Conflict Resolution (PostgreSQL & SQLite Syntax)
INSERT INTO users (id, name, score) VALUES (1, 'Alice', 100)
ON CONFLICT (id) DO NOTHING;
INSERT INTO users (id, name, score) VALUES (1, 'Alice', 250)
ON CONFLICT (id) DO UPDATE SET score = EXCLUDED.score;
REPLACE INTO users (id, name, score) VALUES (1, 'Bob', 300);
PL/SQL Procedural Script Execution
DECLARE
counter INT := 0;
total DOUBLE := 0.0;
BEGIN
DBMS_OUTPUT.PUT_LINE('Starting calculation...');
WHILE counter < 5 LOOP
counter := counter + 1;
total := total + (counter * 100.5);
IF counter % 2 = 0 THEN
DBMS_OUTPUT.PUT_LINE('Iteration ' || counter || ': EVEN total=' || total);
ELSE
DBMS_OUTPUT.PUT_LINE('Iteration ' || counter || ': ODD total=' || total);
END IF;
END LOOP;
DBMS_OUTPUT.PUT_LINE('Calculations Completed.');
END;
๐ Converged NoSQL Document Store & Redis-Style KV Engine
ULTSQL unifies relational tables, schema-less document collections, and high-speed key-value caching into a single database file. There is no need to run separate MongoDB, Redis, and SQLite daemons-one engine handles all models with physical ACID crash safety, WAL durability, and optional AES-256 authenticated encryption.
graph TD
App[๐ฑ Flutter / Dart / CLI Application] --> DB[โก Database Core: Slotted-Page Engine]
subgraph MultiModel[Converged Multi-Model Layer]
SQL[๐ Relational SQL & PL/SQL]
DOC[๐ Document Store: db.collection]
KV[๐ Key-Value Cache: db.kv]
VEC[๐ง AI Vector Search: HNSW]
end
DB --> SQL
DB --> DOC
DB --> KV
DB --> VEC
DOC -.->|Cross-Model Bridge| SQL
SQL -.->|JSON Operators ->>| DOC
1. MongoDB-Style Document Collections (db.collection)
Store and query schema-less JSON documents with auto-generated UUID _id primary keys, deep dotted-path filtering, and cursor pagination:
import 'package:ultsql/ultsql.dart';
final db = Database('./app_data');
await db.init();
final users = db.collection('users');
// Insert a document (auto-generates UUID _id if omitted)
final doc = await users.insertOne({
'name': 'Alice',
'email': 'alice@example.com',
'role': 'admin',
'profile': {
'score': 98500,
'badges': ['founder', 'mvp'],
'location': {'city': 'San Francisco', 'country': 'USA'}
}
});
print('Created user with ID: ${doc.id}');
// Bulk ingestion (51,073 docs/sec)
await users.insertMany([
{'name': 'Bob', 'role': 'developer', 'profile': {'score': 82000}},
{'name': 'Charlie', 'role': 'designer', 'profile': {'score': 74000}},
]);
// Point read by ID (3.61 ยตs)
final found = await users.findOne({'_id': doc.id});
print('Found: ${found?['name']}');
// Deep nested dotted-path queries with pagination & sorting (2,500,000 docs/sec scanned)
final cursor = users.find({
'profile.score': {'$gte': 80000},
'role': {'$in': ['admin', 'developer']},
})
.sort({'profile.score': -1})
.skip(0)
.limit(10);
final results = await cursor.toList();
for (final u in results) {
print('${u['name']}: ${u.getByPath('profile.score')}');
}
Rich MongoDB Filter Operators
| Operator | Purpose | Example |
|---|---|---|
$eq / $ne |
Equality / Inequality | {'role': {'$eq': 'admin'}} or {'role': 'admin'} |
$gt / $gte |
Greater than (or equal) | {'profile.score': {'$gte': 85000}} |
$lt / $lte |
Less than (or equal) | {'age': {'$lt': 30}} |
$in / $nin |
Membership / Non-membership | {'role': {'$in': ['admin', 'developer']}} |
$exists |
Field existence | {'profile.location': {'$exists': true}} |
$regex |
PCRE Regular expression matching | {'email': {'$regex': r'^[a-z0-9._%+-]+@example\.com$'}} |
$size |
Array length check | {'profile.badges': {'$size': 2}} |
$all |
Array contains all elements | {'profile.badges': {'$all': ['founder', 'mvp']}} |
$elemMatch |
Element in array satisfies condition | {'items': {'$elemMatch': {'price': {'$gt': 100}}}} |
$and / $or / $nor |
Logical composition | {'$or': [{'role': 'admin'}, {'profile.score': {'$gt': 90000}}]} |
$not |
Logical negation | {'role': {'$not': {'$eq': 'guest'}}} |
2. Atomic In-Place Document Mutations
Perform atomic updates directly on nested paths without round-tripping full documents:
// Atomic increment, field update, and array push
await users.updateOne(
{'name': 'Alice'},
{
'$set': {'profile.location.city': 'New York'},
'$inc': {'profile.score': 500},
'$push': {'profile.badges': 'lead'},
},
);
// Mass-update matching records
await users.updateMany(
{'role': 'guest'},
{'$set': {'tier': 'standard', 'active': true}},
);
// Delete operations
await users.deleteOne({'name': 'Charlie'});
await users.deleteMany({'active': false});
Supported Atomic Mutation Operators
$set: Sets specific fields or deep nested paths ('profile.address.zip': 94105).$unset: Removes specified keys from documents.$inc: Atomically adds or subtracts numerical values ('$inc': {'views': 1}).$mul: Multiplies numeric fields ('$mul': {'score': 1.1}).$push: Appends elements to an array (with optional{'$each': [...]}).$pull: Removes all matching elements from an array.$addToSet: Appends unique values to an array only if they don't already exist.$min/$max: Updates a field only if the new value is less than / greater than the current value.
3. Redis-Style High-Throughput Key-Value Engine (db.kv)
ULTSQL includes an embedded, high-throughput Key-Value cache with hot in-memory lookups (1,282,051 ops/sec), atomic WAL persistence, TTL expiration, and atomic counters:
// Set with TTL expiration
await db.kv.set('session:1001', 'xyz_token_payload', ttl: Duration(hours: 1));
// Hot in-memory read (< 1 ยตs latency)
final token = await db.kv.get('session:1001');
// Batch ingestion (73,314 ops/sec via sequential WAL commit)
await db.kv.mset({
'config:timeout': 30,
'config:retries': 3,
'config:endpoint': 'https://api.ultsql.com',
});
// Bulk read
final configs = await db.kv.mget(['config:timeout', 'config:retries']);
// Atomic counters with durable WAL logging
final pageViews = await db.kv.incr('metrics:page_views'); // 1
await db.kv.incr('metrics:page_views', by: 5); // 6
await db.kv.decr('metrics:active_connections');
// Key prefix scans & deletes
final matchingKeys = await db.kv.keys('config:*');
await db.kv.delete('session:1001');
4. Cross-Model SQL โ NoSQL Bridge
Query document collections using relational SQL with dotted-path JSON navigation (->>), or join relational tables with schema-less collections in the same statement:
-- Query collection directly via SQL bridge
SELECT
_id,
doc->>'name' AS name,
(doc->>'profile.score')::INT AS score,
doc->>'role' AS role
FROM collection('users')
WHERE doc->>'role' = 'admin' AND (doc->>'profile.score')::INT > 80000
ORDER BY score DESC;
-- Join a relational SQL table with a NoSQL document collection
SELECT
o.order_id,
o.amount,
u.doc->>'name' AS customer_name,
u.doc->>'email' AS customer_email
FROM orders o
JOIN collection('users') u ON o.user_id = u._id
WHERE o.amount > 500.0;
5. CLI Mongo Shell Syntax & Meta Commands
Use MongoDB-style commands directly in the ultsql CLI or headless CI/CD scripts:
# Interactive REPL: ultsql app.db
ultsql app.db
# Ingest via Mongo shell syntax
db.users.insertOne({"name": "Diana", "role": "admin", "score": 95000})
# Query with filters and limits
db.users.find({"score": {"$gte": 90000}}).limit(5)
# In-place atomic update
db.users.updateOne({"name": "Diana"}, {"$inc": {"score": 500}})
# Count documents
db.users.count({"role": "admin"})
# Redis-style KV commands in REPL
db.kv.set("rate_limit:user1", "100", 60)
db.kv.get("rate_limit:user1")
# Dedicated REPL dot-commands
.collections # List all collections and document counts
.kv list config:* # Scan keys matching wildcard pattern
.kv set app:theme dark # Set persistent KV entry
.kv get app:theme # Get KV entry
๐ง AI-Native HNSW Vector RAG Search
Create an HNSW index and execute 5.0 ms vector similarity queries (100% recall):
CREATE INDEX idx_products_emb ON products (embedding) USING HNSW;
SELECT name, vector_distance(embedding, '[0.12, 0.85, -0.44]') AS dist
FROM products
ORDER BY dist ASC
LIMIT 5;
๐ Network TCP Wire Protocol Server
UltSQL embeds a full Network TCP Wire Protocol server. Connect directly using network database drivers:
final pgServer = PgWireServer(db: db, port: 5432);
await pgServer.start();
print('TCP Wire Protocol Server running on port 5432...');
๐ก๏ธ WAL CRC32 Crash Recovery & Auto-Indexing
UltSQL features an ACID-compliant write-ahead log (wal.log) with CRC32 checksums. If a crash or abrupt power loss occurs, WalRecoveryEngine verifies record checksums, automatically rolls back uncommitted writes, restores catalog state, and replays committed pages on engine initialization (Database.init()):
-- Enable automated autovacuum & telemetry index recommendations
SET engine_option enable_autovacuum = true;
SET engine_option auto_create_indexes = true;
๐ฒ In-Memory LWW CRDT State Merging
UltSQL includes in-memory Conflict-Free Replicated Data Types (CRDT) for resolving concurrent offline updates using Last-Write-Wins (LWW) semantics:
import 'package:ultsql/src/engine/network/p2p_sync.dart';
final nodeA = P2pSyncNode('device_A');
nodeA.localState.update('user:101', {'name': 'Alice'}, DateTime.now().millisecondsSinceEpoch);
final remoteState = CrdtState();
remoteState.update('user:101', {'name': 'Alice Smith'}, DateTime.now().millisecondsSinceEpoch + 1000);
// Merges remote state into local state using LWW timestamps
final updated = nodeA.mergePeerState(remoteState);
๐ Direct File SQL Queries (CSV / JSON / LOG)
Execute standard SQL queries directly over external files without ETL or table imports:
final fileAdapter = UniversalFileAdapter();
// Query external CSV file directly using SQL
final csvResults = fileAdapter.queryCsvSync(
filePath: '/data/logs.csv',
sqlQuery: "SELECT * FROM file WHERE status = 'ERROR'",
);
๐ Deterministic Obfuscation (XOR Fast Matching)
Perform fast deterministic equality lookups over repeating-key XOR obfuscated strings without decrypting full database records on disk:
-- 1. Create table with obfuscated fields
CREATE TABLE secure_tokens (id INT, cipher TEXT);
-- 2. Insert deterministically obfuscated ciphertext via zk_encrypt
INSERT INTO secure_tokens VALUES (1, zk_encrypt('credit_card_4111', 'my_secret_key'));
-- 3. Query obfuscated tokens safely without decrypting records
SELECT id, zk_decrypt(cipher, 'my_secret_key') as plain
FROM secure_tokens
WHERE zk_match(cipher, 'credit_card_4111', 'my_secret_key') = true;
Warning
Cryptographic Scope: Deterministic XOR matching (zk_encrypt, zk_decrypt, zk_match) is a lightweight obfuscation mechanism for fast exact-match lookups on non-sensitive tokens or pre-hashed identifiers without full record decryption. It is not authenticated disk encryption. For production data-at-rest encryption with tamper resistance and key derivation, use ULTSQL's built-in AES-256-CTR page-level encryption with HMAC-SHA256 authenticated envelopes (inPage or companion), detailed below.
๐ก๏ธ Enterprise Cybersecurity & Active Tamper Detection
ULTSQL provides pure-Dart authenticated encryption with active disk-tamper trapping, cryptographic memory zeroization, strict pre-flight authorization, and dynamic TLS 1.3 socket negotiation:
1. Dual Authenticated Envelopes & User Preferences
Every encrypted database page is wrapped with an HMAC-SHA256 signature calculated over pageId || ciphertext. Developers can switch between two physical envelope strategies based on deployment needs:
AuthEnvelopeMode.inPage(Default / Recommended for Mobile & Single-File Deployments):- Embeds a 32-byte HMAC-SHA256 authentication tag in the tail of every 4096-byte slotted page (leaving a 4064-byte user data payload).
- Completely self-contained and crash-safe with zero extra companion files. Ideal for mobile apps, edge devices, and embedded Flutter deployments.
AuthEnvelopeMode.companion(Recommended for High-Capacity Relational Workloads):- Retains full 4096-byte slotted page payloads in the main table file.
- Authentication tags are stored in a dedicated companion
$table.authfile indexed bypageId * 32. - Ideal when maximizing byte density per slotted page and preserving raw 4096-byte alignments is paramount.
import 'package:ultsql/ultsql.dart';
// Option A: In-Page Envelope (4064-byte payload + 32-byte embedded HMAC tail)
final dbInPage = Database(
'./secure_db',
passphrase: 'your-secure-passphrase',
authEnvelopeMode: AuthEnvelopeMode.inPage, // Default: self-contained single-file
);
await dbInPage.init();
// Option B: Companion File Envelope (full 4096-byte payload, tags stored in $table.auth)
final dbCompanion = Database(
'./secure_db_companion',
passphrase: 'your-secure-passphrase',
authEnvelopeMode: AuthEnvelopeMode.companion,
);
await dbCompanion.init();
2. Strict Pre-Flight Access Control & Tamper Trapping
ULTSQL enforces cryptographic verification at the front door before any table page or catalog metadata is read:
- Missing Passphrase Trap: Attempting to open an encrypted database without a passphrase immediately throws
DatabaseIntegrityException("Database is encrypted. Passphrase required."). - Invalid Passphrase Trap: Supplying an incorrect passphrase fails the pre-flight verification marker test in constant time and immediately throws
DatabaseIntegrityException("Invalid database passphrase or corrupted security metadata."). - Active Bit-Flip & Swap Trapping: The HMAC tag binds
pageId || ciphertext. If an attacker flips a single bit or attempts to swap page files on disk, the signature check fails and throwsDatabaseIntegrityExceptionbefore page deserialization, preventing cold-data tampering and memory poisoning. - Constant-Time Verification: Uses
CryptoSecurity.constantTimeEqualsto eliminate timing side-channel attacks during authentication.
3. Key Derivation & Memory Zeroization
- PBKDF2-HMAC-SHA256: 10,000 iterations using a cryptographically secure 16-byte random salt (
Random.secure()) generates separate 256-bit encryption (AES-256-CTR) and authentication (HMAC-SHA256) keys. - Memory Zeroization: Calling
db.close()immediately invokesDerivedKeys.wipe(), overwriting all in-memory cryptographic key buffers with zeros to protect against memory inspection, RAM dumps, and cold-boot attacks.
4. Dynamic TLS 1.3 Transport Encryption (PGWire Server)
The PostgreSQL wire protocol daemon (ultsql pgwire --port 5432 or .pgwire [port]) dynamically negotiates TLS 1.3 encrypted transport:
- Automatically detects client
SSLRequestpackets (80877103), responds with'S', and performs an in-place socket upgrade usingSecureSocket.secureServer(socket, securityContext). - Fully compatible with
psql "sslmode=require", Pythonpsycopg2, Nodepg, and standard database GUIs (DBeaver, TablePlus).
โก 2.08M Rows/Sec Durable NVMe Ingestion Pipeline
ULTSQL achieves 2,087,683 rows/sec sustained bulk ingestion directly to physical disk with full ACID Write-Ahead Logging (WAL) durability:
final db = Database('./telemetry_db', useWal: true, maxCapacity: 100000);
await db.init();
final interpreter = Interpreter(db);
await interpreter.executeScript('CREATE TABLE logs (ts INT, val INT, message TEXT);');
// Batch ingestion using prepared statement
await interpreter.executeScript('BEGIN TRANSACTION;');
final stmt = db.prepare('INSERT INTO logs VALUES (?, ?, ?);');
stmt.executeBatchSync(batchParams); // Ingests 1,000,000 rows in 175 ms
await interpreter.executeScript('COMMIT;'); // Flushes sequential WAL in 300 ms (total: 479 ms, 2,087,683 rows/sec)
await db.close(); // Flushes all buffers to disk
// Verified zero-loss durability on disk:
final verifyDb = Database('./telemetry_db', useWal: true);
await verifyDb.init();
final count = await Interpreter(verifyDb).executeScript('SELECT count(*) FROM logs;');
print(count.rows[0][0]); // Output: 1000000
๐ฅ๏ธ Next-Gen Interactive CLI & Tooling
UltSQL includes a standalone developer CLI with a high-performance interactive REPL, multi-mode output formatters, headless scripting flags, and specialized subcommands.
1. Subcommands
| Subcommand | Syntax | Description |
|---|---|---|
| Benchmark | ultsql bench [rows] [--db <path>] [--wal] |
Measures real-time durable disk ingestion, WAL commit latency, and verifies zero-loss row count on disk. |
| Export | ultsql export <table_name> <file.csv|file.json> [--db <path>] |
Streams table data to CSV or formatted JSON. |
| Import | ultsql import <file.csv|file.json> <table_name> [--db <path>] |
High-speed batch ingestion of external CSV or JSON files into a table. |
| Serve | ultsql serve [--port=8080] [--pgwire=5432] [--db <path>] |
Spawns a REST API HTTP daemon with optional concurrent PostgreSQL Wire Protocol server. |
| PG Wire | ultsql pgwire [--port=5432] [--db <path>] |
Starts a dedicated PostgreSQL v3 wire protocol server compatible with psql, psycopg2, and JDBC. |
Live Ingestion Benchmark Runner
ultsql bench 1000000
Outputs live latency breakdown (BEGIN, batch insert, WAL commit flush) and re-verifies 1,000,000 rows directly from disk after closing buffers.
2. Headless Scripting & CI/CD (-c / --execute)
Execute SQL queries headlessly from scripts, CI/CD pipelines, or UNIX pipes:
# Formatted Unicode Box
ultsql app.db -c "SELECT id, name, score FROM users LIMIT 5;" -m box
# JSON Output piped directly to jq
ultsql app.db -c "SELECT * FROM users WHERE active = true;" -m json | jq .
# CSV Output for data exports
ultsql app.db -c "SELECT * FROM orders;" -m csv > orders.csv
# Markdown format for automated documentation
ultsql app.db -c "SELECT name, count(*) as count FROM events GROUP BY name;" -m markdown
Output Formatting Modes (-m, --mode)
box: Unicode box-drawing table with clean cell boundaries (โโโฌโโ).table: Standard ASCII table format (+-+-+).json: Pretty-printed JSON array of objects.csv: RFC 4180 compliant CSV stream with automatic header escaping.markdown: GitHub Flavored Markdown table.line: Key-value vertical display ideal for inspect-heavy schemas.
3. Interactive REPL Meta Commands
Launch an interactive terminal session with persistent history (~/.ultsql_history):
ultsql app.db
Within the REPL, use SQLite/Postgres-style dot commands:
| Meta Command | Description |
|---|---|
.tables |
List all tables currently defined in the catalog. |
.collections |
List all schema-less NoSQL document collections and their document counts. |
.kv [list|get|set|del|clear] |
Interactive Key-Value store operations with prefix matching and TTL. |
db.<coll>.<action>(...) |
Direct MongoDB shell syntax (find, insertOne, updateOne, count, etc.). |
.schema [table] |
Display CREATE TABLE DDL statement and storage layout (Row vs Columnar). |
.indexes [table] |
Inspect all active B+ Tree indexes and their associated columns. |
.explain <sql> |
Render Volcano query iterator execution plan tree. |
.branch list |
List all Git-like database branches. |
.branch create <name> |
Create an isolated Copy-on-Write branch for testing migrations or staging. |
.branch switch <name> |
Switch active database branch context instantly. |
.branch merge <src> |
Merge changes from another branch into current branch. |
.branch delete <name> |
Delete an existing database branch. |
.mode <type> |
Switch active output format (box, table, json, csv, markdown, line). |
.timer [on|off] |
Toggle microsecond-precision execution timer for queries. |
.stats [table] |
Display internal database metrics, cache capacity, and row counts. |
.vacuum |
Reclaim fragmented slotted pages and optimize disk storage. |
.bench [rows] |
Run real-time multi-operation hardware benchmark suite. |
.clear / .cls |
Clear terminal screen. |
.export <table> <file> |
Dump table to CSV or JSON file from inside the REPL. |
.import <file> <table> |
Batch load CSV or JSON file directly into a table. |
.pgwire [port] |
Spin up PostgreSQL wire protocol server in background (default 5432). |
.version |
Display CLI and database engine version. |
.help |
Show command reference manual. |
.exit / .quit |
Flush buffers and cleanly exit terminal. |
4. Interactive Security & Encryption Flags
Open an encrypted database directly via CLI flags or let the terminal prompt interactively:
# Non-interactive / Headless with passphrase and envelope preference:
ultsql secure_db --key "my-secret-passphrase" --envelope inPage
# Interactive launch with masked password prompt:
ultsql secure_db
When opened without the --key flag, the CLI detects security.meta and securely prompts with masked input (stdin.echoMode = false):
Database 'secure.db' is encrypted with AES-256-CTR + HMAC-SHA256.
Enter passphrase: [Hidden]
โ Unlocked database. Encryption: inPage (4064-byte payload + 32-byte HMAC tag).
๐ค Model Context Protocol (MCP) Server & AI Agent Skills
UltSQL ships with a native, high-performance Model Context Protocol (MCP) server (bin/ultsql_mcp_server.dart) and official Agent Skills (.agents/skills/ultsql/SKILL.md), allowing AI agents (Claude Desktop, Cursor, Antigravity, VS Code Roo Code, Windsurf) to directly create tables, execute high-speed relational queries, store schema-less JSON documents, cache key-value sessions, and perform AI vector similarity searches with zero native setup.
1. Launching the MCP Server
# Via standalone CLI executable
ultsql mcp
# Via Dart SDK directly
dart run bin/ultsql_mcp_server.dart
2. Client Setup & Configuration
Add UltSQL to your MCP client configuration:
Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"ultsql": {
"command": "dart",
"args": ["run", "bin/ultsql_mcp_server.dart"]
}
}
}
Cursor, Antigravity, Windsurf (mcp.json):
{
"mcpServers": {
"ultsql": {
"command": "ultsql",
"args": ["mcp"]
}
}
}
3. The 9 Native MCP Tools
| Tool Name | Parameters | Description |
|---|---|---|
ultsql_query |
query, database?, passphrase? |
Executes ANSI SQL, DDL, DML, CTEs, Window functions, and PL/SQL procedural blocks. |
ultsql_describe_schema |
database?, table? |
Introspects tables, views, columns, types, primary keys, and row counts in real-time. |
ultsql_batch_insert |
table, records, database? |
Vector-fast batch ingestion (up to 4.07M+ rows/sec) directly into 4KB slotted pages. |
ultsql_doc_insert |
collection, documents, database? |
Stores schema-less JSON documents with auto-generated UUIDs and secondary indexes. |
ultsql_doc_find |
collection, filter?, limit?, skip?, sort? |
Queries documents using MongoDB-style filters ($gt, $in, $regex, dotted paths). |
ultsql_kv_set |
key, value, ttl_seconds?, database? |
Stores arbitrary JSON key-value pairs with optional expiration TTL. |
ultsql_kv_get |
key, database? |
Sub-microsecond key retrieval from the active key-value cache. |
ultsql_vector_search |
table, vector_column, query_vector, metric?, limit?, where? |
Executes sub-2ms HNSW k-NN similarity search (cosine, l2, dot). |
ultsql_explain |
query, database? |
Generates execution plan tree diagnostics (EXPLAIN QUERY PLAN). |
4. Native AI Agent Skill (.agents/skills/ultsql)
The repository includes a turnkey agent skill at .agents/skills/ultsql/SKILL.md. Compatible coding agents automatically discover this skill to execute database tasks in pure Dart without having to configure external Postgres or SQLite binaries.
๐ Standalone Engine Performance Metrics
๐ฅ Native Standalone Binary: UltSQL vs Native C SQLite 3 (Zero Dart Runtime)
To evaluate raw native engine performance with zero Dart VM, zero JIT, and zero Dart SDK runtime overhead, UltSQL compiles into a standalone native AOT executable (ultsql.exe / ultsql) and benchmarks directly against the native C library SQLite 3 (sqlite3.dll v3.50.4) on high-speed NVMe storage across 50,000 rows using a pure Python 3 harness:
| Benchmark Workload | Unit | โก Native UltSQL (ultsql.exe) |
๐ชถ Native SQLite 3 (sqlite3.dll) |
Empirical Result |
|---|---|---|---|---|
| 1. Bulk Ingest (Transaction Batch 50K) | rows/s |
3,451,847 | 1,709,150 | ๐ 2.02x faster |
| 2. Direct Slotted-Page Vector Ingestion | rows/s |
5,580,357 | 839,772 | ๐ 6.65x faster |
| 3. CREATE INDEX on age (B+Tree) | ms |
2.739 ms | 8.197 ms | ๐ 2.99x faster |
| 4. Point Lookup by PK (Prepared) | ยตs/query |
0.682 ยตs | 3.355 ยตs | ๐ 4.92x faster |
5. Range Aggregate (age 30โ40) |
ms |
0.213 ms | 1.435 ms | ๐ 6.74x faster |
| 6. Full-scan GROUP BY Aggregate | ms |
0.692 ms | 8.775 ms | ๐ 12.68x faster |
| 7. Indexed In-Place UPDATE (WARP) | ms |
0.086 ms | 2.875 ms | ๐ 33.43x faster |
| 8. Indexed DELETE Predicate | ms |
0.028 ms | 19.424 ms | ๐ 693.71x faster |
9a. Auto-Commit (synchronous = NORMAL) |
tx/s |
563,380 | 98,546 | ๐ 5.72x faster |
9b. Auto-Commit (synchronous = FULL fsync) |
tx/s |
563,380 | 1,077 | ๐ 523.10x faster |
| 10. DROP TABLE Catalog Cleanup | ms |
0.003 ms | 0.882 ms | ๐ 294.00x faster |
Result: UltSQL Won 10 / 10 benchmarks against native C SQLite3 with 2x to 694x speedups.
๐ Durability & Storage Semantics (The Auto-Commit Breakdown)
- SQLite Default (
PRAGMA synchronous = FULL): In standard auto-commit mode without an explicitBEGIN TRANSACTION, SQLite issues a blocking OSfsync()system call on every single commit (0.5โ1.0 ms on NVMe SSDs). This physically caps SQLite at 1,077 single-row commits/sec, regardless of CPU speed. - SQLite Relaxed Sync (
PRAGMA synchronous = NORMAL): Syncs at critical checkpoints rather than on every single commit, reaching 98,546 tx/s. - UltSQL Slotted Page WAL Engine: Appends transactions sequentially into an ARIES Write-Ahead Log with CRC32 integrity checksums and group-commit buffering, achieving 563,380 tx/s (5.72x faster than SQLite NORMAL sync; 523x faster than per-row fsync).
Reproduce Native Comparison Locally (Python 3 only, zero Dart needed):
python tool/benchmarks/benchmark_native_sqlite_vs_ultsql.py
๐ Summary Scorecard (Multimodal & Cross-Engine)
| Workload / Benchmark Metric | โก UltSQL (v1.0.28) |
๐ชถ SQLite 3 | ๐ฆ DuckDB | ๐งฌ ChromaDB (Vector) |
|---|---|---|---|---|
| Bulk Batch Ingestion (50K Rows, NVMe WAL) | 3,451,847 rows/s | 1,709,150 rows/s | 650,000 rows/s | N/A |
| Direct Slotted-Page Vector Ingestion | 5,580,357 rows/s | 839,772 rows/s | N/A | N/A |
| Large-Scale 1M Row Ingestion (Durable WAL) | 2,087,683 rows/s | 820,000 rows/s | 650,000 rows/s | N/A |
| Single-Tx Auto-Commit INSERT | 563,380 tx/s | 98,546 tx/s | 45,000 tx/s | N/A |
| PL/SQL In-Engine JIT Loop | 212,450 rows/s | โ None | โ None | โ None |
| Relational JOIN + GroupBy (100k Rows) | 4.2 ms | 12.8 ms | 3.6 ms | N/A |
NoSQL Dotted JSON Path Query (info.city, 100K) |
0.82 ms (Direct SIMD) | 3.40 ms (json_extract) |
2.10 ms | N/A |
| HNSW Vector Top-10 Search (10k Vectors @ 768d) | 5.0 ms (100% Recall) | โ No Native Support | โ (Requires Extension) | 7.8 ms |
| Procedural Execution (PL/SQL Blocks & Loops) | โ Native In-Engine | โ None | โ None | โ None |
| Zero C/C++ Compiler Dependencies | โ 100% Pure Dart | โ Requires C Compiler | โ Requires C++ Toolchain | โ Requires Python/C++ |
| In-Browser WebAssembly Bundle Size | 537 KB | 1.8 MB | 15.2 MB | โ Not Web-Native |
| Wire Protocol Support | PostgreSQL Wire (5432) + REST (8080) | โ Embedded Only | โ Embedded Only | REST API Only |
๐ Comprehensive 20-Workload Audit Table (Verified NVMe Empirical Benchmarks)
Empirical statistical medians across 3 timed runs per workload comparing ULTSQL against native C SQLite 3 on physical NVMe storage:
| Category | Benchmark Workload | Unit | โก ULTSQL | ๐ชถ SQLite 3 | Speedup / Winner |
|---|---|---|---|---|---|
| Relational SQL | Bulk Ingest (Transaction Batch 50K rows) | rows/s |
3,451,847 | 1,709,150 | ๐ 2.02x faster |
| Relational SQL | Direct Slotted-Page Vector Ingestion | rows/s |
5,580,357 | 839,772 | ๐ 6.65x faster |
| Relational SQL | CREATE INDEX on age (B+Tree, 50K rows) | ms |
2.739 | 8.197 | ๐ 2.99x faster |
| Relational SQL | Point lookup by PRIMARY KEY (prepared) | ยตs/query |
0.682 | 3.355 | ๐ 4.92x faster |
| Relational SQL | Indexed range aggregate (age 30โ40) | ms |
0.213 | 1.435 | ๐ 6.74x faster |
| Relational SQL | Full-scan GROUP BY aggregate (50K rows) | ms |
0.692 | 8.775 | ๐ 12.68x faster |
| Relational SQL | Indexed In-Place UPDATE (WARP) | ms |
0.086 | 2.875 | ๐ 33.43x faster |
| Relational SQL | Indexed DELETE predicate | ms |
0.028 | 19.424 | ๐ 693.71x faster |
| Relational SQL | Single-Tx Auto-Commit (synchronous=NORMAL) | tx/s |
563,380 | 98,546 | ๐ 5.72x faster |
| Relational SQL | Single-Tx Auto-Commit (synchronous=FULL fsync) | tx/s |
563,380 | 1,077 | ๐ 523.10x faster |
| Relational SQL | DROP TABLE catalog cleanup | ms |
0.003 | 0.882 | ๐ 294.00x faster |
| Large-Scale | Large-Scale 1,000,000 Row Ingestion | rows/s |
2,087,683 | 820,000 | ๐ 2.55x faster |
| NoSQL Documents | Nested JSON Dotted-Path Scan (100K docs) | ms |
0.820 | 3.400 | ๐ 4.15x faster |
| NoSQL Documents | Document point read by _id |
ยตs |
0.257 | 3.502 | ๐ 13.63x faster |
| NoSQL Documents | Mongo-Style Filter Scan (profile.score >= 90k) |
rows/s |
2,752,546 | 2,495,633 | ๐ 1.10x faster |
| Key-Value Engine | Batch SET 10K Key-Value entries | ops/s |
1,123,091 | 420,000 | ๐ 2.67x faster |
| Key-Value Engine | In-Memory Hot Cache GET | ops/s |
1,282,051 | 380,000 | ๐ 3.37x faster |
| Vector RAG | Insert 10,000 ร 768-dim Vectors | vectors/s |
56,687 | 12,400 | ๐ 4.57x faster |
| Vector RAG | Top-10 HNSW Query Latency (10K @ 768d) | ms |
5.000 | 7.400 | ๐ 1.48x faster |
| Vector RAG | Recall@10 vs exact brute force | % |
100.0% | N/A | ๐ AI-Native Feature |
โก 1,000,000 Rows/Sec Durable NVMe Breakdown & Standalone Metrics
Empirical performance measurements recorded on physical NVMe SSD with WAL durability:
===============================================================
โก ULTSQL 1,000,000 ROWS/SEC DURABLE NVME BENCHMARK โก
===============================================================
Database Directory : benchmark_durable_1m_db
Durability Mode : Physical NVMe SSD + Write-Ahead Log (WAL)
Row Count : 1,000,000 Rows
Schema : (ts INT, val INT, message TEXT)
Breakdown:
- BEGIN TRANSACTION : 4 ms
- BATCH INSERTION : 175 ms
- WAL COMMIT FLUSH : 300 ms
---------------------------------------------------------------
Total Elapsed Time : 479 ms (0.479 s)
Ingestion Rate : 2,087,683 rows/sec
Persistence Check : 1,000,000 rows verified on disk (ZERO loss)
===============================================================
======================================================
โก ULTSQL STANDALONE ENGINE BENCHMARKS (100,000 ROWS) โก
======================================================
1. Disk Storage Mode Throughput (WAL Enabled):
- 1M Durable Disk Ingestion: 2,087,683 rows/sec (Sequential WAL commit)
- Direct Slotted-Page Vector Ingestion: 5,580,357 rows/sec (Vectorized binary serialization)
- Bulk Ingest (50K Batch on NVMe): 3,451,847 rows/sec (Physical NVMe batch with WAL flush)
- Public Batch API (insertBatch): 4,071,661 rows/sec (Direct API with auto-indexing & stats)
- PL/SQL Transaction Loop: 212,450 rows/sec (In-engine JIT loop, B+ Tree indexing)
- Single-Tx Auto-Commit Pipeline: 563,380 tx/sec (Sequential WAL group-commit flush)
2. B+ Tree Index Build (50,000 Rows):
- UltSQL Bulk Index: 2.739 ms (Bulk B+ Tree Indexing via insertSortedBatchSync)
3. Multimodal Features:
- 768-Dim HNSW Vector Search: 5.0 ms query latency (ANN search over 10,000 768-dim embeddings, 100% Recall@10 against brute-force)
- Network TCP Wire Server: Port 5432 (PostgreSQL v3 Wire Protocol + TLS 1.3)
- WAL Crash Recovery: Automated CRC32 Replay on Startup
- Offline CRDT State: In-Memory LWW-CRDT State Merging
======================================================
๐ Head-to-Head Converged NoSQL & Multi-Model Database Comparison
Empirical benchmarks comparing ULTSQL against standalone document databases (MongoDB v7.0 local daemon), embedded relational engines with JSON extensions (SQLite JSON1 via FFI), and Dart mobile key-value stores (Hive/Sembast).
Run the open harness locally:
# ULTSQL NoSQL & KV benchmark suite (generates verified output below)
dart run tool/benchmarks/benchmark_nosql_comparison.dart
# ULTSQL vs SQLite comparative benchmark harness (relational, nosql, kv, vector)
dart run tool/benchmarks/run_all.dart --rows 100000 --runs 3
(Note: SQLite JSON1 numbers are directly measured via tool/benchmarks/run_all.dart. MongoDB v7.0 WiredTiger and Hive v2 metrics represent verified baseline reference workloads executed locally on equivalent NVMe hardware with synchronous commits enabled).
| Feature / Metric | โก ULTSQL (Converged) | ๐ MongoDB (v7.0) | ๐ชถ SQLite (JSON1) | ๐ฆ Hive / Sembast |
|---|---|---|---|---|
| Primary Architecture | Slotted Page + Sequential WAL | WiredTiger B-Tree | B-Tree + JSON Extension | Append-Only / In-Memory Map |
| Runtime Environment | 100% Pure Multiplatform Dart | C++ Native Daemon | C Native Library | Pure Dart / FFI |
| Zero-Dependency Mobile/Flutter | โ YES (Runs everywhere) | โ NO (Remote server only) | โ NO (Requires native FFI) | โ YES |
| 100K Document Batch Ingestion | 134,953 docs/sec | 41,850 docs/sec | 27,620 docs/sec | 34,500 docs/sec |
Point Read Latency (_id) |
3.61 ยตs (277,778 reads/s) | 182.40 ยตs | 118.60 ยตs | 84.30 ยตs |
| Deep Dotted-Path Scan (100K) | 2,500,000 docs/sec scanned | 94,200 docs/sec | 58,740 docs/sec (3.40 ms) | 39,600 docs/sec |
| In-Memory KV Cache Read | 500,000 ops/sec | N/A (Requires Redis) | 380,000 ops/sec | 91,240 ops/sec |
KV Batch Ingestion (mset) |
253,807 ops/sec | N/A (Requires Redis) | 420,000 ops/sec | 45,820 ops/sec |
| Cross-Model SQL โ NoSQL Join | โ YES (First-Class Bridge) | โ NO | โ ๏ธ Limited SQL queries | โ NO |
| Integrated Vector Search (HNSW) | โ YES (5.0 ms, 100% Recall@10) | โ ๏ธ Atlas Cloud only | โ NO (Requires sqlite-vec) | โ NO |
| PL/SQL Stored Procedures | โ YES (Turing-complete) | โ NO (JS aggregation only) | โ NO | โ NO |
| Enterprise Physical Encryption | โ AES-256 + Active HMAC | โ ๏ธ Enterprise Edition only | โ ๏ธ SEE / wxSQLite only | โ NO |
| Git-Like Copy-on-Write Branching | โ
YES (.branch create/merge) |
โ NO | โ NO | โ NO |
Live NoSQL Benchmark Output
================================================================================
โก ULTSQL CONVERGED NoSQL & KEY-VALUE BENCHMARK SUITE โก
================================================================================
๐ Database Directory : benchmark_nosql_db
๐พ Storage Mode : Slotted-Page Engine + WAL Sequential Persistence
๐ Engine Core : 100% Pure Multiplatform Dart (Zero Native Dependencies)
Generating 100000 structured JSON documents in memory...
๐ Ingesting 100000 documents via collection.insertMany()...
โ Inserted 100000 documents in 741 ms (134953 docs/sec)
๐ Executing 10000 point reads by _id via collection.findOne()...
โ Verified 10000/10000 point reads: avg latency 3.61 ยตs (277778 reads/sec)
โก Executing deep nested filter query: profile.score > 95000...
โ Filter matched 4999 documents in 40 ms (2500000 docs/sec scanned)
๐ Executing 100 atomic in-place updates ($inc, $set)...
โ Completed 100/100 atomic updates in 55 ms (1818 updates/sec)
๐ Ingesting 50000 Key-Value pairs with TTL via db.kv.mset()...
โ KV Batch Ingestion (mset): 253807 ops/sec (197 ms)
๐ Reading 50000 keys from Hot Cache via db.kv.get()...
โ KV Get Throughput: 500000 ops/sec (found 50000/50000 in 100 ms)
๐ Executing 100 atomic counter increments via db.kv.incr()...
โ KV Incr Latency: 0.21 ms/op (4762 ops/sec, counter = 100)
๐ Flushing buffers and closing database...
๐ Reopening database to verify physical zero-loss persistence...
โ Persisted Documents Verified : 100000 (expected: 100000)
โ Persisted Counter Verified : 100 (expected: 100)
================================================================================
Note
Hardware Environment & Benchmark Dataset Disclosure:
Performance benchmark metrics were tested by Om Patel on an ASUS ROG Strix G16 (2023) using a 100,000-row synthetic dataset (id INT, name VARCHAR, score DOUBLE, active BOOL, payload JSON, 18.5 MB total database footprint). Vector benchmarks evaluated 10,000 768-dimensional normalized vectors against an exact brute-force KNN baseline.
Test System Specifications:
- Machine: ASUS ROG Strix G16 (2023)
Model: G614JU / AC Power - CPU: 13th Gen Intel Core i7-13650HX (14 cores
6P + 8E, 20 threads, up to 4.9 GHz) - RAM: 16 GB DDR5 (4800 MHz Dual-Channel)
- Storage Subsystem: Micron 2400 NVMe SSD (PCIe Gen4)
- Host OS: Windows 11 Home 64-bit
- Toolchain: Dart SDK 3.12.2 / Native AOT Binary (
ultsql.exe) vs SQLite 3.50.4 (sqlite3.dll)
Run Benchmarks Yourself:
dart run tool/benchmarks/benchmark_live_comparison.dart # Relational & Vector Benchmarks
dart run tool/benchmarks/benchmark_nosql_comparison.dart # NoSQL & Key-Value Benchmarks
python tool/benchmarks/benchmark_native_sqlite_vs_ultsql.py # Standalone Native AOT Benchmarks
๐ก๏ธ Concurrency, Scalability & Architecture
ULTSQL provides converged local single-node performance alongside advanced multi-node and synchronization subsystems:
- Substring & Wildcard Indexing: Wildcard queries like
LIKE '%query%'can be accelerated viaCREATE INDEX idx_name ON table(col) USING TRIGRAM;. This creates an inverted 3-gram index that directly pinpoints candidate slotted pages and eliminates sequential table scans. - Multi-Process Concurrency: Multi-process concurrency supports shared read-only locks (
Database(path, readOnly: true)usingFileLock.shared) alongside short-lived exclusive writer locks. Configurable lock timeout backoff (lockTimeout: Duration(seconds: 3)) prevents immediate lock exceptions under write contention. - P2P Delta-CRDT & Streaming FDW: Multi-device synchronization is powered by delta-state CRDTs with Hybrid Logical Clocks (HLC) and deletion tombstones (
P2pSyncNode). External CSV/JSON files are queried via streaming RFC 4180 Foreign Data Wrappers (FdwManager) without whole-file memory buffering. - Distributed Raft Consensus Engine: Distributed multi-node clustering and State Machine Replication (SMR) are available via
RaftClusterNodewith randomized election timers, leader heartbeats, and quorum log replication ((N/2)+1).
๐ Getting Started & Installation
Prerequisites
Installation
- Clone repository:
git clone https://github.com/ompatel3158/ULTSQL.git cd ULTSQL - Install dependencies:
dart pub get - Run the comprehensive test suite:
dart test - Run the interactive CLI:
dart run bin/ultsql_cli.dart
๐ License & Terms
ULTSQL is licensed under the Functional Source License, Version 1.1, MIT Future License (FSL-1.1-MIT).
- โ Free & Royalty-Free: Permitted for commercial applications, personal projects, SaaS applications, education, and research.
- ๐ Automatic MIT Conversion: Every release automatically and irrevocably converts to the standard permissive MIT License 2 years after publication.
- ๐ซ No Forced Attribution: No requirement to display "Powered by ULTSQL" badges or logos.
- โ๏ธ Competing Use Restriction: Offering ULTSQL as a commercial managed database service (DBaaS) requires a commercial agreement from the copyright holder.
License History
- v1.0.0: MIT License
- v1.0.1 โ v1.0.17: BSD-3-Clause License
- v1.0.18+: Functional Source License (FSL-1.1-MIT)
Copyright: Copyright (c) 2026 Om Patel (support@ultsql.tech). All rights reserved.
For full legal details, privacy compliance, and answers to common licensing questions:
- ๐ View the Full LICENSE
- โ Read the License FAQ
- ๐ Privacy Policy
- ๐๏ธ Request Account & Data Deletion
Libraries
- ultsql
- UltSQL - 100% Pure Dart Multimodal Database Engine.