sql

The SQL you'd write on paper.
Now actually works.

Window functions, correlated subqueries, aggregate over expression, CASE WHEN, predicate pushdown, EXPLAIN ANALYZE — the SQL surface customers asked for in demos, now shipped.

query.sqlSELECT id, nameFROM customers cWHERE EXISTS (SELECT 1 FROM orders o ...)semi-joinindex scancustomersrows 1.2kindex scanorders(customer_id)rows 40kEXPLAIN ANALYZE - est vs actual per node
the surface

Six families. All shipping today.

Every construct below runs in production, against the same atomic substrate as vector, graph and full-text — one engine, one write, one bill.

Filters & expressions
WHERELIKE / ILIKEIS [NOT] NULLcol vs colCASE WHENexpressions in SELECT

Predicates push down to secondary indexes — the planner splits conjuncts and routes each to the cheapest index.

Joins
JOINCROSS JOINcomma joinsup to 32 tables

Left-deep planner across as many as 32 tables. The cap used to be 5; real schemas needed more.

Aggregates
GROUP BYSUM / AVG / MIN / MAX / COUNTCOUNT(DISTINCT)SUM(qty * price)HAVING + OR

Aggregates wrap any expression, not just bare columns. HAVING composes with OR.

Window functions
ROW_NUMBERRANK / DENSE_RANKLAG / LEADSUM…COUNT OVER

A streaming partition walk on top of the index scan — no spool, no extra storage.

Subqueries
IN / NOT INEXISTScorrelated EXISTS / IN / scalar

Correlated EXISTS rewrites to a semi-join and rides the same index walker as the outer WHERE.

DDL & integrity
CREATE TABLEforeign keysCHECK constraintsmaterialized views

FK on-delete: NoAction, Restrict, SetNull. CHECK with 3-valued logic. MVs install / refresh / read on demand.

the planner, live

Ask the engine what it did, not what it meant to do.

EXPLAIN ANALYZE returns the plan with estimated and actual rows per node. When the two drift apart, you've found your slow query before your users do.

A correlated EXISTS below becomes a semi-join; each side rides its own index. No cursors, no per-row subquery execution.

explain analyze
> EXPLAIN ANALYZE SELECT … WHERE EXISTS (…);

semi_join                      est 1.1k · actual 1.2k · 3.1 ms
├─ index_scan customers(region)   est 1.3k · actual 1.2k
└─ index_scan orders(customer_id) est 41k  · actual 40k

point lookup < 5 ms · GROUP BY 10k < 50 ms · EXISTS over 100k < 80 ms
in practice

Two queries that used to be a "no."

top payment per user
SELECT user_id, amount,
  ROW_NUMBER() OVER (
    PARTITION BY user_id
    ORDER BY ts DESC) AS rn
FROM payments;
customers with open orders
SELECT id, name
FROM customers c
WHERE EXISTS (
  SELECT 1 FROM orders o
  WHERE o.customer_id = c.id
    AND o.status = 'open');
next

The full construct list lives in the docs.