Summary
Roadmap item (README "Next"; DESIGN.md section 6 lists secondary indexes as an honest v1 deferral for both the document and relational lenses). Today every find()/where() is an O(n) collection scan by design; secondary indexes are the single largest lever on the query surface.
Why
- The performance envelope (README) documents the O(n) scan honestly; indexes move the practical ceiling for read-heavy workloads.
- The kernel already provides everything an index needs: ordered byte keys, composite-key ranges, and atomic multi-key transactions — an index is a lens-level convention (
<reserved>index:<ns>:<field>:<value>:<id> style keys), not a kernel feature.
Scope sketch (exploratory — each choice must earn its place against the comprehension budget)
- Index maintenance inside the same
transact() as the row write (atomic by construction).
- A catalog entry per index so cold-opening tools (Studio) can render them; reserved-namespace placement.
- Query planning stays trivial: equality-predicate lookup via index when one exists, scan otherwise — no planner.
- Open questions: value encoding for ordered numeric keys, index backfill for existing data, multi-field indexes (defer?).
Constraints
- Kernel (
src/core.ts) unchanged — this is lens-level, open-edge work.
- No silent behavior changes to unindexed queries.
- Changeset (minor) when it ships;
bun run gate green with 100% coverage.
Summary
Roadmap item (README "Next"; DESIGN.md section 6 lists secondary indexes as an honest v1 deferral for both the document and relational lenses). Today every
find()/where()is an O(n) collection scan by design; secondary indexes are the single largest lever on the query surface.Why
<reserved>index:<ns>:<field>:<value>:<id>style keys), not a kernel feature.Scope sketch (exploratory — each choice must earn its place against the comprehension budget)
transact()as the row write (atomic by construction).Constraints
src/core.ts) unchanged — this is lens-level, open-edge work.bun run gategreen with 100% coverage.