toondb-query

Crates.iotoondb-query
lib.rstoondb-query
version0.3.4
created_at2026-01-01 03:42:22.362819+00
updated_at2026-01-08 05:54:30.333999+00
descriptionToonDB query engine (sync-first execution and vector query planning)
homepagehttps://toondb.dev
repositoryhttps://github.com/toondb/toondb
max_upload_size
id2015709
size1,085,287
Sushanth Reddy (sushanthpy)

documentation

https://docs.toondb.dev

README

toondb-query

Query planning and execution engine for ToonDB.

Overview

toondb-query provides the query layer for ToonDB, 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]
toondb-query = "0.2.5"

Usage

Most users should use the high-level toondb crate:

use toondb::{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
toondb High-level client API (start here)
toondb-core Core types and traits
toondb-storage Storage engine with WAL
toondb-index HNSW vector indexing
toondb-query Query execution (this crate)

License

Apache-2.0 - see LICENSE for details.

Commit count: 98

cargo fmt