DB
Concepts

Indexes

Secondary indexes in NYXDB — bitmap, minmax, set, bloom, and HNSW — built per part and rebuilt on compaction.

Secondary indexes are declared per column and stored per part: each sealed part carries its own index region, built at seal time and rebuilt when parts compact. Indexes are maintained on the committed tail too, so pruning applies to unflushed rows.

Declaring an index

The inline form declares an index inside CREATE TABLE (or via CREATE INDEX):

INDEX idx_amount amount TYPE minmax
INDEX bm_base_mint base_mint TYPE bitmap
INDEX idx_email email TYPE set

Grammar: INDEX <name> <column> TYPE <type> [GRANULARITY n]. The index_granularity table setting controls the default granule width.

Index types

bitmap

Exact-match, high-cardinality; supports AND/OR across predicates. Granule-level by default, opt-in row-level.

minmax

Min/max bounds for range pruning. Per-part regions prune whole parts (and granules) for range predicates.

set

Distinct-value list; prunes a part when the queried value is provably absent.

bloom

Probabilistic presence test for data-skipping.

hnsw

Approximate nearest-neighbor for vector(N) similarity search.

Data-skipping vs. lookup

minmax, set, and bloom are data-skipping indexes: they answer "could a matching row be in this part/granule?" and let the scanner skip provably-empty regions. bitmap is a lookup index: it maps values to positions and can intersect predicates.

Per ADR-046 and follow-on work, minmax and set are maintained as per-part regions, so a range or membership predicate can prove a whole part empty and skip it entirely. The declared-set per-part region and its AND-fold scan path are landing now. (TODO-verify: ADR-082 as a standalone document — this behavior is currently anchored in ADR-046's index model.)

Vector search (HNSW)

Vector similarity uses vector(N) columns and an hnsw index (built per part at flush, vendored usearch). A bare INDEX hnsw defaults to the cosine metric, and an ORDER BY <distance>(col, $q) LIMIT k query rewrites to the VectorTopK operator.

-- HNSW on an attribute vector column (cosine default)
CREATE TABLE emb_t (id UInt64, ATTRIBUTE (emb vector(8) INDEX hnsw));

-- ANN search — rewrites to VectorTopK
SELECT id, cosine_distance(emb, '[1,0,0,0,0,0,0,0]')
FROM emb_t
ORDER BY cosine_distance(emb, '[1,0,0,0,0,0,0,0]')
LIMIT 3;

Available distance functions include cosine_distance, cosine_similarity, l2_distance, inner_product, dot_product, and negative_inner_product. See Vector search for the full ANN path, and data types.

On this page