Architecture & Core Concepts

Unified ACID/MVCC + SSI transactions, row/columnar/schemaless storage, multi-tenancy, and protocol selection.

3 min read Getting Started

SpydDB unifies transactional OLTP storage, analytical columnar segments, schema-flexible JSON documents, BM25 full-text search, HNSW vector search, R-Tree geospatial queries, streaming change capture, and OpenTelemetry observability into a single Rust storage and execution engine.

Single-Snapshot ACID & SSI Guarantee#

Every statement — whether submitted over SpydQL, PostgreSQL wire (:5432), SpydWire (:5433), HTTP JSON (:8080), or Embedded Web Studio — executes inside one MVCC + Serializable Snapshot Isolation (SSI) transaction boundary:

  • No eventual-consistency sync lag: Secondary B-Tree indexes, BM25 full-text inverted indexes, HNSW vector graphs, R-Tree geo indexes, and keyed HMAC blind indexes commit in the exact same atomic WAL transaction as the primary row.
  • No split security perimeter: Role-Based Access Control (RBAC), row-level filter and deny policies, role-scoped field masks, ABAC session attributes, and SHA-256 hash-chained audit logging apply uniformly across every protocol listener.

Multi-Model Storage Layouts#

Model / LayoutDeclarationBest Fit
Row Store (B+ Tree)create collection users { id: u64 primary, ... }Point lookups, high-concurrency OLTP updates, unique constraints, foreign keys
Columnar / PAX Segmentsstore column for (ts, service, latency_ms) or columnarWide analytical scans, group-by aggregations, zone-map min/max pruning, cold archival
Schemaless JSON Documentscreate collection events { id: u64 primary, schemaless }Rapidly evolving event payloads, flexible metadata, json_text() extraction
Time-Ordered Data Streams & ILMcreate data stream logs on events by ts stages { hot, warm after 7d, delete after 30d }Append-heavy logs, telemetry, automated warm compaction and TTL expiry

Automatic Hot / Cold Tiering#

Row-oriented collections can age inactive rows into compressed immutable columnar segments automatically (tiering_interval_secs, hot_cold_threshold_secs) while keeping 100% of historical rows transparently queryable from the same SQL/SpydQL statements.

Logical Boundaries: Databases vs. Multi-Tenancy#

SpydDB supports two distinct isolation primitives:

  1. Databases (CREATE DATABASE / X-Spyd-Database / use_database):
    • Separate catalogs, collections, roles, policies, and search paths inside one spyd-server process.
    • Manage dynamically over pgwire (CREATE DATABASE analytics) or the Admin REST API (/v1/admin/databases), and select per session via use_database("analytics") or HTTP header X-Spyd-Database: analytics.
  2. Physical Multi-Tenancy (security.multi_tenant_enabled):
    • Prefixes every row key, index entry, encryption envelope AAD, and columnar segment family with an immutable 8-byte tenant_id bound directly to the authenticated credential.
    • Enforces independent per-tenant byte/row quotas and per-query memory, wall-clock, and row limits.

Choosing Your Protocol#

ProtocolPortTransportBest For
SpydWire (SPD2)5433Framed TCP/TLSLowest latency across all 10 native SDKs with full typed precision (u64, Decimal, Vector, GeoPoint)
PostgreSQL Wire (v3)5432TCP / SSLRequest TLSExisting tools (psql, DataGrip, DBeaver), Python psycopg/SQLAlchemy, Node pg, Java JDBC, ODBC, BI connectors
HTTP/1.1 & OTLP8080HTTPS REST & Protobuf/JSONServerless/edge functions, browser SPAs, curl, admin automation, OpenTelemetry ingestion (/v1/traces, /v1/metrics, /v1/logs)
gRPC / OTLPconfigured grpc_bindHTTP/2 TLSHigh-throughput OpenTelemetry Collector pipelines

Next Steps#