SynapCores Query Optimizer
Target Audience: Solution Architects, Technical Decision Makers, Database Engineers
Executive Summary
The SynapCores Query Optimizer represents a significant advancement in AI-native database performance optimization. Built entirely in Rust for maximum performance and safety, it picks an access path to fit each predicate: B-tree indexes serve equality and range filters, hash indexes serve equality lookups, HNSW indexes serve top-k similarity search, and BM25 full-text indexes serve MATCH ... AGAINST. EXPLAIN shows the plan it chose, and EXPLAIN ANALYZE measures that plan on your own data and hardware.
Key Value Propositions
- Filters pushed into the scan: equality and range predicates run inside the index or table scan, so joins and vector scoring see only matching rows
- HNSW top-k search:
ORDER BYthe similarity function that matches the index metric, thenLIMIT k, and the plan reads the HNSW index - Zero-configuration deployment for immediate performance gains
- Measured on your hardware:
EXPLAIN ANALYZEruns the query and reports the plan with its actual time and rows
Unique Differentiators
Unlike traditional database optimizers that treat AI/ML as an afterthought, SynapCores' optimizer is purpose-built for AI-native workloads:
- Native Vector Operation Optimization: First-class support for vector similarity operations and semantic search
- ML Inside the Query:
EMBED()computes embeddings in SQL,CREATE EXPERIMENTtrains models andPREDICTscores rows, all next to the data - Rust Performance: Zero-cost abstractions and memory safety without garbage collection overhead
- Unified Architecture: One planner covers relational filters, joins, BM25 full-text search and vector top-k, so a hybrid query runs as a single plan
- Plans You Can Inspect:
EXPLAINshows the operator tree and the index each scan uses, andEXPLAIN (FORMAT JSON)returns it for tooling
The AI-Native Database Challenge
Modern applications increasingly combine traditional relational operations with AI/ML workloads:
- Semantic search over product catalogs using vector embeddings
- Real-time fraud detection combining SQL aggregations with ML inference
- Multimodal queries joining structured data with image/text similarity
- Hybrid OLTP/OLAP workloads requiring both transaction and analytical performance
Traditional database optimizers, designed before widespread AI adoption, struggle with these workloads. They lack native understanding of:
- Vector distance metrics and the indexes that serve them
- Embedding generation as part of the query
- ML model inference as query operators
- Semantic similarity vs. keyword matching trade-offs
Optimization Architecture
Query Execution Pipeline
SQL Query Input
|
v
+------------------+
| SQL Parser | Custom dialect with AI extensions
+------------------+ Parses: SQL + VECTOR ops + ML functions
|
v
+------------------+
| AST -> Logical | Converts parse tree to executable plan
| Plan | Handles: joins, filters, projections
+------------------+
|
v
+-----------------------------------------------------+
| UNIFIED QUERY OPTIMIZER |
| |
| +-----------------------------------------------+ |
| | Stage 1: Rewrite Rules | |
| | Fast, always-beneficial transformations | |
| | - Constant Folding (evaluate at compile) | |
| | - Predicate Pushdown (filters to scans) | |
| | - Projection Pushdown (named columns) | |
| | - Filter Merging (combine AND predicates) | |
| | See it: EXPLAIN lists scan predicates | |
| +-----------------------------------------------+ |
| | |
| v |
| +-----------------------------------------------+ |
| | Stage 2: Access Paths | |
| | Each scan gets the index that fits it | |
| | - Primary key: point lookups | |
| | - B-tree: equality and range filters | |
| | - Hash: equality lookups | |
| | - HNSW: ORDER BY similarity ... LIMIT k | |
| | - BM25 full-text: MATCH ... AGAINST | |
| | See it: EXPLAIN names the chosen index | |
| +-----------------------------------------------+ |
+-----------------------------------------------------+
|
v
+------------------+
| Optimized Plan | Ready for execution
| Executor | EXPLAIN ANALYZE: actual time and rows
+------------------+
Core Optimization Techniques
Join Planning
Problem: Join order dramatically affects query performance. A poorly ordered 5-table join can produce far larger intermediate results than a well-ordered one.
SynapCores Approach: the plan joins tables in the order your FROM clause lists them, and pushes each table's filters into its own scan, so every join sees only the rows that match. You choose the join order, and EXPLAIN shows it:
EXPLAIN SELECT c.name, o.order_id, o.total_spend
FROM customers c
JOIN orders o ON o.customer_id = c.id
WHERE c.region = 'east'
AND o.order_date >= '2025-01-01'
With a B-tree index on orders (order_date), the plan joins customers to orders in that order (operator lines from EXPLAIN):
Projection
InnerJoin
TableScan
table: customers
IndexScan
table: orders, index: idx_orders_order_date
Each scan also lists its scan predicates: region = 'east' on customers and the order_date filter on orders. List the most selective table first, index the filter columns, and compare the alternatives with EXPLAIN ANALYZE on your own data.
Performance Impact
Check the join plan on your own workload:
| What to Check | How |
|---|---|
| Join tree and join conditions | EXPLAIN shows each InnerJoin with its on: condition |
| Filters applied in each table scan | EXPLAIN lists them as scan predicates on the TableScan or IndexScan |
| Indexes used | EXPLAIN names the index on each IndexScan |
| Actual time and rows | EXPLAIN ANALYZE runs the query on your data and hardware |
Projection Pushdown
Problem: Reading unnecessary columns wastes I/O bandwidth and memory.
Example: name the columns the query uses instead of SELECT *.
Before:
SELECT customer_id, total_spend
FROM (
SELECT * FROM orders WHERE order_date > '2025-01-01'
) subquery
JOIN customers ON customers.id = subquery.customer_id
After:
SELECT customer_id, total_spend
FROM (
SELECT customer_id, total_spend, order_date
FROM orders WHERE order_date > '2025-01-01'
) subquery
JOIN customers ON customers.id = subquery.customer_id
Check it: EXPLAIN lists the columns each subquery projects, and EXPLAIN ANALYZE times both forms on your own data and hardware.
Primary-Key Point Lookups
Problem: OLTP workloads repeat small lookups by key, thousands of times with different values.
SynapCores Solution: an equality on the primary key reads the row through the table's primary-key index, with no table scan:
EXPLAIN SELECT product_id, name, price FROM products WHERE product_id = 42
Projection
IndexScan
table: products, index: products_pkey
On Your Workload: send repeated OLTP queries as one parameterized statement ($1 placeholders with a parameters array on POST /v1/query/execute), and track the execution_time_ms that each response reports.