store: Consolidate index creation using CreateIndex and add postponed index support by lutter · Pull Request #6434 · graphprotocol/graph-node
added 12 commits
March 10, 2026 17:29…able All callers used the name of the table that was passed in, except for the use in `copy.rs`, but copying doesn't change table names, so the src and dst names of tables are the same if they exist in the dst
Consolidate index creation into a single `Table::indexes()` method that returns all indexes (time-travel, attribute, aggregate) as `CreateIndex` objects. This replaces the old string-based methods and eliminates the `index_def: Option<IndexList>` parameter threading through the codebase. Key changes: - Add `Table::indexes()` combining time_travel + attribute + aggregate indexes - Add `attr_index_spec()` and `add_attribute_indexes()` structured helpers - Move env var check into `CreateIndex::to_postpone()` so callers need not check - Simplify `Table::as_ddl()` to iterate indexes with postpone filtering - Remove old `create_time_travel_indexes`, `create_attribute_indexes`, `create_postponed_indexes`, `create_aggregate_indexes` string methods - Remove `index_def` parameter from Layout, DeploymentStore, SubgraphStore - Update copy.rs to use `indexes()` + `references_column_not_in()` for new fields - Update prune.rs to use simplified `as_ddl()` without index_def - Update all DDL test constants for new single-line index format
Add a trigger that creates postponed indexes when a subgraph gets within a configurable number of blocks (default 10000) of the chain head. This ensures indexes are in place before the subgraph starts serving queries. The new env var GRAPH_POSTPONE_INDEXES_CREATION_THRESHOLD controls how many blocks before the chain head to trigger index creation. The creation is idempotent (IF NOT EXISTS + CONCURRENTLY) and only attempted once per subgraph run via an AtomicBool guard.
Replace the IndexList-based `recreate_invalid_indexes` call in `start_subgraph()` with a call to `create_postponed_indexes()`. This uses `IF NOT EXISTS` and `CONCURRENTLY` to safely create any missing postponed indexes on every restart, acting as a safety net. Remove the now-unused `IndexList::recreate_invalid_indexes` method.
isum approved these changes Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters