1
0
mirror of https://github.com/TwiN/gatus.git synced 2026-03-22 15:00:07 +00:00

perf: Add PostgreSQL indexes for ~15x performance improvement (#1541)

fix: missing indexes are added to improve postgresql performance

Co-authored-by: TwiN <twin@linux.com>
This commit is contained in:
Ozan Onur TEK
2026-02-25 07:39:07 +03:00
committed by GitHub
parent c4900ced6c
commit c7f0b85ba1

View File

@@ -120,5 +120,9 @@ func (s *Store) createPostgresSchema() error {
_, _ = s.db.Exec(`ALTER TABLE endpoint_results ADD COLUMN IF NOT EXISTS suite_result_id BIGINT REFERENCES suite_results(suite_result_id) ON DELETE CASCADE`) _, _ = s.db.Exec(`ALTER TABLE endpoint_results ADD COLUMN IF NOT EXISTS suite_result_id BIGINT REFERENCES suite_results(suite_result_id) ON DELETE CASCADE`)
// Create index for suite_result_id // Create index for suite_result_id
_, _ = s.db.Exec(`CREATE INDEX IF NOT EXISTS endpoint_results_suite_result_id_idx ON endpoint_results(suite_result_id)`) _, _ = s.db.Exec(`CREATE INDEX IF NOT EXISTS endpoint_results_suite_result_id_idx ON endpoint_results(suite_result_id)`)
// Create index for endpoint_result_conditions
_, _ = s.db.Exec(`CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_endpoint_result_conditions_endpoint_result_id ON endpoint_result_conditions (endpoint_result_id)`)
// Create index for endpoint_results
_, _ = s.db.Exec(`CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_endpoint_results_endpoint_id ON endpoint_results (endpoint_id)`)
return err return err
} }