sochdb-query

Crates.iosochdb-query
lib.rssochdb-query
version0.4.3
created_at2026-01-12 17:10:08.867819+00
updated_at2026-01-23 20:34:38.437567+00
descriptionSochDB query engine (sync-first execution and vector query planning)
homepagehttps://sochdb.dev
repositoryhttps://github.com/sochdb/sochdb
max_upload_size
id2038226
size1,168,312
Sushanth Reddy (sushanthpy)

documentation

https://sochdb.dev

README

sochdb-query

Query planning and execution engine for SochDB.

Overview

sochdb-query provides the query layer for SochDB, featuring:

  • Query Builder: Fluent API for constructing queries
  • Query Optimizer: Cost-based optimization for efficient execution
  • Projection Pushdown: Only read columns you need
  • Filter Pushdown: Apply filters at storage layer
  • TOON Output: Token-optimized format (40-66% fewer tokens than JSON)

Features

  • SQL-like Queries: Familiar query patterns without SQL parsing overhead
  • Path-based Access: O(|path|) resolution independent of data size
  • Aggregations: COUNT, SUM, AVG, MIN, MAX with efficient execution
  • Sorting & Pagination: ORDER BY, LIMIT, OFFSET support
  • Join Support: Nested loop and hash joins

Installation

[dependencies]
sochdb-query = "0.2.5"

Usage

Most users should use the high-level sochdb crate:

use sochdb::{Database, Query};

let db = Database::open("./my_data")?;

// Query with builder pattern
let results = db.query("users")
    .filter("age", ">", 21)
    .select(&["name", "email"])
    .order_by("name")
    .limit(10)
    .execute()?;

// Results in token-efficient TOON format
println!("{}", results.to_toon()); 
// users[3]{name,email}: Alice,alice@...|Bob,bob@...|Carol,carol@...

Query Execution Pipeline

┌──────────────┐
│    Query     │  User query (builder or path)
└──────┬───────┘
       │
       ▼
┌──────────────┐
│    Parse     │  Validate and normalize
└──────┬───────┘
       │
       ▼
┌──────────────┐
│   Optimize   │  Pushdown filters, projections
└──────┬───────┘
       │
       ▼
┌──────────────┐
│   Execute    │  Scan, filter, project, sort
└──────┬───────┘
       │
       ▼
┌──────────────┐
│   Format     │  TOON or JSON output
└──────────────┘

Crate Structure

Crate Purpose
sochdb High-level client API (start here)
sochdb-core Core types and traits
sochdb-storage Storage engine with WAL
sochdb-index HNSW vector indexing
sochdb-query Query execution (this crate)

License

Apache-2.0 - see LICENSE for details.

Commit count: 121

cargo fmt