Skip to main content

Module database

Module database 

Source
Expand description

SochDB Database Kernel

The shared core that powers both embedded mode (SochConnection::open) and server mode (sochdb-server). This is the “SQLite engine” equivalent.

§Architecture

┌──────────────────────────────────────────────────────────────────┐
│                        Database Kernel                            │
│  Arc<Database> - shared by all connections                       │
├──────────────────────────────────────────────────────────────────┤
│                                                                   │
│  ┌─────────────────┐   ┌─────────────────┐   ┌────────────────┐ │
│  │  DurableStorage │   │     Catalog     │   │  Vector Index  │ │
│  │  (WAL + MVCC)   │   │  (Schema Mgmt)  │   │  (HNSW/Vamana) │ │
│  └────────┬────────┘   └────────┬────────┘   └───────┬────────┘ │
│           │                     │                     │          │
│           └─────────────────────┴─────────────────────┘          │
│                                 │                                 │
│  ┌─────────────────────────────────────────────────────────────┐ │
│  │              Query Executor (Path-Native)                    │ │
│  │  - Path resolution: O(|path|)                                │ │
│  │  - Column projection: 80% I/O reduction                     │ │
│  │  - Context selection: Token-aware chunking                  │ │
│  └─────────────────────────────────────────────────────────────┘ │
│                                                                   │
└──────────────────────────────────────────────────────────────────┘

Deployment Modes:
┌─────────────┐   ┌─────────────┐   ┌─────────────┐
│  Embedded   │   │  IPC Server │   │  TCP Server │
│  (in-proc)  │   │  (Unix sock)│   │  (remote)   │
└──────┬──────┘   └──────┬──────┘   └──────┬──────┘
       │                 │                 │
       └─────────────────┴─────────────────┘
                         │
                  Arc<Database>

§Latency Model

Let K = kernel processing cost for a query

  • Embedded: L_emb ≈ K (function call overhead negligible)
  • IPC: L_ipc ≈ K + δ_ipc (δ_ipc = ~10-50µs for Unix socket)
  • TCP: L_tcp ≈ K + δ_net (δ_net = 100µs-10ms depending on network)

For LLM context queries where K >> δ_ipc, IPC is “nearly embedded”.

Re-exports§

pub use crate::durable_storage::RecoveryStats;

Structs§

ColumnDef
Column definition
ColumnarQueryResult
Columnar query result - SIMD-friendly format for analytics
ColumnarRowView
Zero-allocation row view into a ColumnarQueryResult.
Database
The SochDB Database Kernel
DatabaseConfig
Database configuration
GroupCommitSettings
Group commit settings - mirrors SQLite’s WAL mode tuning
QueryBuilder
Query builder for fluent query construction
QueryResult
Query result from the kernel
QueryRowIterator
Lazy iterator over query results
Stats
Public statistics snapshot
TableSchema
Table schema for the kernel
TxnHandle
Transaction handle for kernel operations
VectorSearchResult
Vector search result

Enums§

ColumnType
Column types
SyncMode
WAL sync mode - matches SQLite’s PRAGMA synchronous semantics