Index (secondary)
In one line: mark a component field
[Index]and Typhon maintains a sorted B+Tree so it can be looked up directly instead of scanned.
A plain field can only be found by scanning the archetype. [Index] builds and maintains an index behind the scenes; a query that targets that field (WhereField<Team>(t => t.Id == 3)) is served from the index rather than a broad scan, and stays cheap as the archetype grows. [Index] is unique (a duplicate key throws UniqueConstraintViolationException); [Index(AllowMultiple = true)] lets many entities share a value.
You never touch the tree — you declare the index and filter on the field. An IndexRef is the handle when you resolve one directly.
How it relates
- Component — an index is declared on a component field.
- Query — a
WhereFieldfilter on an indexed field drives a targeted (fast) scan. - View — an indexed
WhereFieldpredicate backs an incremental live view. - Storage mode — index freshness/maintenance timing follows the component's mode.
- Spatial index — the geometric sibling, for "what's near here?".
In the API
IndexRef— the index-resolution handle.[Index]/[Index(AllowMultiple = true)]— the field attributes (declaration-only, not in the API reference).
Learn & use
- Narrative: Guide ch.2 §3 — indexes
- Feature detail: indexing · lookup & range scan · secondary-index storage modes