schema compile · 1000 models
Lex + parse + validate the .zanith source into a runtime graph. Sub-linear at scale because validation reuses tokenization state.
engine/test/benchmark/scale.test.tsProof · 01 — The receipts
Every figure on this page comes from a benchmark or proof file in the engine repo, with the source named below it. The disclosures at the bottom are part of the page, not buried.
$ npx vitest run test/proof/Test Files 7 passed (7)Tests 53 passed (53)Duration 8.54s
schema compile · 1000 models
Lex + parse + validate the .zanith source into a runtime graph. Sub-linear at scale because validation reuses tokenization state.
engine/test/benchmark/scale.test.ts1000 model lookups
Indexed lookup against the in-memory model registry. Sub-microsecond per call — well below any human-perceptible threshold.
engine/test/benchmark/scale.test.tsgraph memory · 1000 models
Total memory footprint of the runtime graph at 1k models. Order of magnitude smaller than a comparably-sized generated client on disk.
engine/test/benchmark/scale.test.ts| operation | shape | cost | group |
|---|---|---|---|
| Expression · simple eq | { field: value } | 1.2µs | expression |
| Expression · AND/OR | { AND: [a, b], OR: [c, d] } | 2.4µs | expression |
| SELECT · with WHERE | where + projection | 2.4µs | compile |
| findMany · build + compile | args validate + AST + emit | 2.1µs | compile |
| JOIN · projection · WHERE | 1 included relation | 17.2µs | compile |
| GROUP BY + COUNT + SUM | aggregate compile | 5.5µs | compile |
| INSERT · single row | RETURNING * | 2.8µs | write |
| UPSERT · ON CONFLICT DO UPDATE | deduped by unique field | 2.7µs | write |
| Bulk INSERT · 10 rows | values list | 7.6µs | write |
engine/test/benchmark/execution.test.ts$ pnpm testvitest run · zanith engine✓ test/compiler/select.test.ts (8)✓ test/compiler/insert.test.ts (5)✓ test/benchmark/scale.test.ts (6) 427ms✓ test/benchmark/execution.test.ts (1) 466ms✓ test/proof/06-flagship-claims.test.ts (16)Test Files 74 passed (74)Tests 765 passed (765)Duration 2.14s
tsc --noEmit. Every claim below is backed by a test you can re-run.test/proof/00-system-report.test.tsMachine metadata, cold/warm compile distribution, SQL snapshots for relation-heavy queries.
test/proof/01-large-schema.test.ts1,000 models · 3,967 directed relation edges · self-relations · m2m · 5-hop chain · duplicate FKs.
test/proof/02-relation-correctness.test.tsCompile → execute → assert rows. One-hop, multi-hop, self-relation, duplicate joins, m2m, LEFT/INNER.
test/proof/03-type-inference.test.tsexpectTypeOf positives + // @ts-expect-error negatives. Gate is tsc --noEmit, not vitest alone.
test/proof/04-preflight-shadow.test.tsaddUnique / addForeignKey / NOT NULL blocks with sample rows. Shadow apply + drift detection.
test/proof/05-backfill-recovery.test.ts10k-row crash-resume from checkpoint. archiveColumn round-trip + checksum tamper rejection.
test/proof/06-flagship-claims.test.tsDestructive gate, soft-drop, archive round-trips, reseed — adversarial proofs of migrate safety claims.
Domain refA / refB / refC75%
3 belongsTo per Domain model (989 × 3)
Audit FKs → User25%
createdBy / updatedBy / approvedBy on every 3rd Domain
Chain · m2m · self · fixtures0%
5-hop Chain · PostTag · User.manager · Post.author · m2m
SELECT "domain_0"."id", "domain_0"."slug"FROM "domain_0" AS "domain_0"WHERE "domain_0"."active" = TRUELIMIT $1-- params: [10]
SELECT "chain0"."id" AS "topId","next_5"."label" AS "deepestLabel"FROM "chain0" AS "chain0"LEFT JOIN "chain1" AS "next" ON "chain0"."next_id" = "next"."id"LEFT JOIN "chain2" AS "next_2" ON "next"."next_id" = "next_2"."id"LEFT JOIN "chain3" AS "next_3" ON "next_2"."next_id" = "next_3"."id"LEFT JOIN "chain4" AS "next_4" ON "next_3"."next_id" = "next_4"."id"LEFT JOIN "chain5" AS "next_5" ON "next_4"."next_id" = "next_5"."id"
SELECT "domain_0"."id","createdBy"."email" AS "creator","updatedBy"."email" AS "updater","approvedBy"."email" AS "approver"FROM "domain_0" AS "domain_0"LEFT JOIN "users" AS "createdBy" ON "domain_0"."created_by_id" = "createdBy"."id"LEFT JOIN "users" AS "updatedBy" ON "domain_0"."updated_by_id" = "updatedBy"."id"LEFT JOIN "users" AS "approvedBy" ON "domain_0"."approved_by_id" = "approvedBy"."id"LIMIT $1
Phase 1 commits 4 batches (2,000 rows) then throws. Phase 2 resumes from _zanith_migration_checkpoints — no duplicates.
findings the suite surfaced
m2m junction column-name bug
The m2m emit hard-codes junction.fromField / junction.toField as the literal column name in the join's ON clause — it does not route through the junction model's columnName mapping. Workaround documented in 02-relation-correctness.test.ts.
Shadow-verify representation gap
Even matching plans report residual createTable + dropTable drift. Real drift IS still caught — the rawSql case proves the gate works — but verifyOnShadowOrThrow is currently over-strict on matching plans.
4 explicit gaps · 2 tracked · 0 hidden
Every µs on this page is engine overhead. Network latency, connection setup, and the database's actual execution time are excluded.
on this page · Per-op compile in µs — engine time only, not round-trip
We don't have sourced competitor figures yet. Specific µs comparisons will land when we can run a matched workload on each.
on this page · Our numbers are pinned from vitest — competitors need matched workloads first
The 3.4MB figure is the steady-state graph footprint. We haven't yet measured memory under continuous schema reloads or sustained query throughput.
on this page · Single compile heap delta @ 1k models — not sustained churn
We measure what we emit, not how the planner reacts. The /examples page shows the SQL we generate; production tuning lives downstream.
on this page · Generated SQL specimens — planner behavior is yours to tune
Generated SQL and compile costs live on /examples. Competitor benches will ship when we can run matched workloads — tracked openly above.
# 1. create the dedicated test database (idempotent) $ psql -h localhost -d postgres \ $ -c "DROP DATABASE IF EXISTS zanith_proof_tests" \ $ -c "CREATE DATABASE zanith_proof_tests" # 2. run all seven proof files $ npx vitest run test/proof/ # 3. confirm type assertions under tsc — vitest strips types $ npx tsc --noEmit
Override the connection string with ZANITH_PROOF_DB_URL if the default doesn't match your local Postgres.
Per-operation compile costs also live on /examples#compile-cost.
the architecture that makes these numbers possible
/how-it-worksreal schemas with their generated SQL — the operations measured above
/exampleswhat's shipped, what's in flight, what's planned next
/roadmapfull reference for queries, schema, migrate, and production
/docselsewhere