perf: add database indexes to commonly queried entity fields#217
Open
sameh-farouk wants to merge 1 commit intomaster-docs-updatefrom
Open
perf: add database indexes to commonly queried entity fields#217sameh-farouk wants to merge 1 commit intomaster-docs-updatefrom
sameh-farouk wants to merge 1 commit intomaster-docs-updatefrom
Conversation
2f756ea to
89ed0ef
Compare
3ea7db0 to
319b7bb
Compare
89ed0ef to
b62e44a
Compare
319b7bb to
6bd4b06
Compare
b62e44a to
4195ae0
Compare
6bd4b06 to
e92e002
Compare
4195ae0 to
288ce73
Compare
e92e002 to
2a3a713
Compare
288ce73 to
c52d7b6
Compare
2a3a713 to
d93b222
Compare
Add @index directives to schema.graphql for 25 fields across 9 entities, based on analysis of actual query patterns from all downstream consumers: - GraphQL API consumers: tfgrid-sdk-ts (grid_client, playground, dashboard), tfgrid-sdk-go (grid-client, relay-cache-warmer) - Direct DB consumer: grid-proxy reads the processor's PostgreSQL directly via GORM/SQL Indexed fields: - Twin: twinID - Farm: farmID, name, twinID, dedicatedFarm - PublicIp: ip - Node: nodeID, farmID, twinID, certification - NodeContract: contractID, twinID, nodeID, state - NameContract: contractID, twinID, state - RentContract: contractID, twinID, nodeID, state - ContractBillReport: contractID, timestamp - UptimeEvent: nodeID, timestamp No table/column changes — migration contains only CREATE INDEX statements. Grid-proxy's setup.sql indexes (IF NOT EXISTS) coexist without conflict. No processor reindex needed. Fixes: #216 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
c52d7b6 to
1d9718c
Compare
d93b222 to
1e96cca
Compare
Member
Author
|
Tetsed on test vm |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #216. Adds 25 database indexes across 9 entities based on analysis of actual query patterns from all downstream consumers.
Research
Analyzed GraphQL queries and direct SQL access across:
Grid-proxy already creates some indexes in its
setup.sql, but they get lost on processor DB reset. This PR makes them part of the processor's migration.Full research details in #216 comments.
Indexed fields (25 total)
What changed
schema.graphql— added@indexdirective to 25 fieldssrc/model/generated/*.model.ts— regenerated byyarn codegenwith@Index_()decoratorsdb/migrations/1775123913074-Data.js— new migration with 25CREATE INDEXstatementsBackward compatibility
CREATE INDEXstatementssetup.sqlindexes useCREATE INDEX IF NOT EXISTS— they coexist without conflictTest plan
yarn buildpassesCREATE INDEXstatements, no other alterations