Unwired Index Structures
Every structure on this page compiles and most have unit tests, but no wire and no SQL statement reaches it. They are listed so that readers of src/index/ know what is and is not in the query path. The wired indexes are described in the overview.
| Structure | File | Has tests | Page |
|---|---|---|---|
IndexManager |
src/index/mod.rs |
No | This page |
DiskAnnIndex |
src/index/diskann.rs |
No | This page |
IVFPQIndex |
src/index/ivf_pq.rs |
No | This page |
TieredVectorIndex |
src/index/tiered.rs |
Yes (config and stats only) | This page |
TantivyIndex, SimpleFullTextIndex
|
src/index/fulltext.rs |
Yes | Full-text search |
GraphAdjacencyIndex |
src/index/graph.rs |
Yes | Graph adjacency index |
BTreeIndex, persistent B+tree |
src/index/btree.rs, src/index/btree_persistent/
|
Yes | B-tree and hash |
src/index/gin.rs |
src/index/gin.rs |
Yes | GIN |
(source: src/index/mod.rs, module declarations; files as listed)
The HNSW graph in src/index/hnsw.rs is wired: the SQL KNN path and the vector service use it. See HNSW and pgvector.
IndexManager
Not wired: no code outside src/index/ calls any of its create_* methods, so every map in it stays empty. (source: src/index/mod.rs, IndexManager; repository-wide search for create_*_index callers)
IndexManager holds:
| Field | Type |
|---|---|
btree_indexes |
DashMap<u32, BTreeIndex> keyed by column id |
persistent_btree_indexes |
DashMap<u32, Arc<PersistentBTree>> |
vector_indexes |
DashMap<u32, Box<dyn VectorIndex + Send + Sync>> (HNSW or tiered) |
fulltext_indexes |
DashMap<u32, TantivyIndex> |
gin_indexes |
DashMap<u32, Arc<GinIndex>> |
graph_index |
Option<GraphAdjacencyIndex> (one per manager) |
(source: src/index/mod.rs, IndexManager)
Methods: create_btree_index, create_persistent_btree_index, open_persistent_btree_index, create_vector_index, create_tiered_vector_index, create_fulltext_index, create_gin_index, create_graph_index, the matching get_* accessors, and get_indexes_for_column, which returns AvailableIndex values tagged with IndexKind { BTree, PersistentBTree, Vector, FullText, Gin, Graph }. (source: src/index/mod.rs, IndexManager, AvailableIndex, IndexKind)
The traits it stores are Index, VectorIndex (insert, delete, search, search_with_threshold, dimension, len), GraphIndex and FullTextIndex. (source: src/index/mod.rs, trait definitions)
The query engine creates an empty IndexManager and consults it on insert, delete and in execute_full_text_search, which no parser reaches; PhysicalPlanner, the other reader, is only built in its own tests. Both points are covered in the overview.
src/types/schema.rs declares IndexType { BTree, Hash, Hnsw { m, ef_construction }, DiskAnn { r, l }, IvfPq { nlist, m }, FullText, Graph }. Nothing builds an index from the DiskAnn, IvfPq, FullText or Graph variants. (source: src/types/schema.rs, IndexType)
DiskANN (DiskAnnIndex)
Not wired: referenced only from src/index/ (tiered.rs uses it as the warm tier). Not verified: the file has no tests. (source: src/index/diskann.rs; src/index/tiered.rs)
Parameters
| Constant | Value | Used |
|---|---|---|
DEFAULT_R |
64 | Maximum out-degree when a node's own list is pruned |
DEFAULT_L |
200 | Expansion limit during insert |
DEFAULT_ALPHA |
1.2 | Declared, not used by any pruning step |
(source: src/index/diskann.rs, constants)
On-disk layout
| File | Content |
|---|---|
<data_dir>/<name>.vectors |
Raw little-endian f32; vector i at byte offset i * dim * 4
|
<data_dir>/<name>.diskann |
bincode DiskAnnState (nodes, neighbour lists, entry point, record map), written by save and read by load
|
new truncates the vectors file, so creating an index over an existing name discards its vectors. (source: src/index/diskann.rs, new, save, load, DiskAnnState)
Behaviour
- Insert: greedy search from the entry point, expanding up to L nodes, then keeps the R nearest as the new node's neighbours and adds reverse edges. The prune of a neighbour whose list overflows is computed on a temporary list and discarded, so existing nodes can exceed R. Inserting an existing id only rewrites its vector, not its edges.
-
Delete: removes the node from its neighbours' lists and from the record map, but keeps the node, its vector and any other inbound edges.
lenstill counts it and a search can still reach and return it. - Search: expands every reachable node with no L bound, reads each visited vector from disk while holding the state write lock, and trims the candidate list to 2k before returning k.
(source: src/index/diskann.rs, insert, delete, search, len)
IVF-PQ (IVFPQIndex)
Not wired: referenced only from src/index/tiered.rs as the cold tier. Not verified: the file has no tests. (source: src/index/ivf_pq.rs; src/index/tiered.rs)
| Constant | Value |
|---|---|
DEFAULT_N_CLUSTERS |
256 |
DEFAULT_M (subvectors) |
8 |
DEFAULT_BITS |
8 (256 codes per subvector) |
dimension must be divisible by m. (source: src/index/ivf_pq.rs, constants, IVFPQIndex::new)
The index is never trained:
- Cluster centroids are drawn uniformly from [-1, 1) at construction and never updated.
- Every product-quantization codebook is initialized to zero vectors and never written, so every subvector encodes to code 0 and every reconstructed vector is all zeros.
Distances computed from these codes do not reflect the stored vectors, so search results carry no ranking information. n_probe is min(8, max(1, n_clusters / 4)), so at most 8 clusters are probed. The structs derive Serialize, but there is no save or load. (source: src/index/ivf_pq.rs, IVFPQIndex::new, PQCodebook, quantize, reconstruct, search)
Tiered vector index (TieredVectorIndex)
Not wired: only IndexManager::create_tiered_vector_index builds one, and nothing calls that. (source: src/index/mod.rs, create_tiered_vector_index; src/index/tiered.rs)
Tiers
| Tier | Structure | Location |
|---|---|---|
| Hot | HnswIndex |
Memory |
| Warm | DiskAnnIndex |
<data_dir>/<index_name>_warm; a creation error is dropped with .ok() and the tier is left empty |
| Cold | IVFPQIndex |
Memory |
(source: src/index/tiered.rs, TieredVectorIndex::new)
TieredIndexConfig defaults
| Field | Default |
|---|---|
hot_threshold_secs |
3600 |
warm_threshold_secs |
604800 (7 days) |
cold_threshold_secs |
2592000 (30 days); not read by determine_tier
|
data_dir |
./data |
index_name |
default |
migration_interval_secs |
60 |
max_migrations_per_cycle |
1000 |
enable_background_migration |
true |
(source: src/index/tiered.rs, TieredIndexConfig, Default) Tested by test_tiered_config_default.
determine_tier maps age since last access to Hot below the hot threshold, Warm below the warm threshold, otherwise Cold. Tested by test_determine_tier. (source: src/index/tiered.rs, determine_tier)
Behaviour
- Insert always goes to the hot tier and keeps a copy of the vector in the per-record metadata, so memory use does not drop when a record moves down.
- Search queries all three tiers, updates the access time of each hit and merges by distance.
-
Migration:
background_migrationandpromote_to_hotmove records between tiers when called. Themigration_workerfield isNoneafternew, andstart_migration_worker_with_sharedneeds shared handles the struct does not keep, so no background thread runs even withenable_background_migrationset. -
Counters:
MigrationStatskeeps atomic counts per direction, cycles, errors, last cycle time and tier sizes. Tested bytest_migration_stats_snapshot.
(source: src/index/tiered.rs, insert, search, background_migration, promote_to_hot, start_migration_worker_with_shared, MigrationStats)
Not verified: no test inserts into or searches a TieredVectorIndex.
Third-party crates
dashmap (IndexManager maps), parking_lot (locks), bincode (DiskANN state), rand (IVF-PQ centroids), serde (derives), tantivy (full-text). (source: src/index/mod.rs, src/index/diskann.rs, src/index/ivf_pq.rs, imports; Cargo.toml)