Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

query_router Benchmarks

The query router integrates all engines and routes queries based on parsed AST type.

Relational Operations

OperationTime
SELECT * (100 rows)17 us
SELECT WHERE17 us
INSERT290 us
UPDATE6.5 ms

Graph Operations

OperationTime
NODE CREATE2.3 us
EDGE CREATE3.5 us
NEIGHBORS1.8 us
PATH (1 -> 10)85 us
FIND NODE1.2 us

Vector Operations

OperationTime
EMBED STORE (128d)28 us
EMBED GET1.5 us
SIMILAR LIMIT 5 (100 vectors)10 ms
SIMILAR LIMIT 10 (100 vectors)10 ms

Mixed Workload

ConfigurationTimeQueries/s
5 mixed queries (SELECT, NEIGHBORS, SIMILAR, INSERT, NODE)11 ms455/s

Insert Throughput

Batch SizeTimeRows/s
10029 ms3.4K/s
500145 ms3.4K/s
1,000290 ms3.4K/s

Analysis

  • Parse overhead: Parser adds ~200ns-2us per query (negligible vs execution)
  • Routing overhead: AST-based routing is O(1) pattern matching
  • Relational: SELECT is fast (17us); UPDATE scans all rows (6.5ms for 100 rows)
  • Graph: Node/edge creation ~2-3us; path finding scales with path length
  • Vector: Similarity search dominates mixed workloads (~10ms for 100 vectors)
  • Bottleneck identification: SIMILAR queries are the slowest operation; use HNSW index for large vector stores

Query Routing Flow

Query String
    │
    ▼
┌─────────┐
│ Parser  │  ~500ns
└────┬────┘
     │
     ▼
┌─────────┐
│   AST   │
└────┬────┘
     │
     ▼
┌─────────────┐
│   Router    │  O(1) dispatch
└──────┬──────┘
       │
       ├──► RelationalEngine
       ├──► GraphEngine
       ├──► VectorEngine
       ├──► Vault
       ├──► Cache
       └──► BlobStore

Performance Recommendations

Query TypeOptimization
High SELECT volumeCreate hash indexes on filter columns
Large vector searchBuild HNSW index
Graph traversalsUse NEIGHBORS with LIMIT
Batch insertsUse batch_insert() API
Mixed workloadsProfile to identify bottlenecks