Indexes
Expression indexes, index lifecycle and how the planner uses them.
Create an index
Declare indexes with expression selectors - single fields, nested fields and compound keys:
orders.CreateIndex(x => x.Country); // single field
orders.CreateIndex(x => x.ShippingAddress!.City); // nested field
orders.CreateIndex(x => new { x.Country, x.Status }); // compound key
The planner uses an index when a filter matches it; query explanation shows which index answered a query and which were refused, and why. Full-text and vector indexes are covered on their own pages.
Index lifecycle
Every index - scalar, vector or full-text - is a versioned generation tied to a checkpoint, with an explicit lifecycle. If maintenance fails, the index is marked degraded, and the degradation survives a restart. The planner never uses an index that is not ready, so answers stay correct at the cost of a scan until it is rebuilt. Building an index does not hold the collection still.
Things to know
- Range queries over a sorted index iterate linearly: correct, not fast.
- The planner chooses a single index with a scoring heuristic; it has no cost model.
- There is no online incremental index build: a checkpoint mismatch triggers a full background rebuild, served by scan fallback meanwhile.
- Index definitions are not logged in the WAL; they are derived state, reconstructed and checkpoint-verified.