From 88c7a6537a534d4e1b6619144dc0f77c3c8d41e5 Mon Sep 17 00:00:00 2001 From: Caleb Doxsey Date: Thu, 10 Jul 2025 12:14:20 -0600 Subject: [PATCH] postgres: drop redundant indices (#5715) ## Summary There are 3 indices in the postgres storage driver that are redundant. This PR drops them. ## Related issues - [ENG-2560](https://linear.app/pomerium/issue/ENG-2560/request-remove-redundant-database-indexes) ## Checklist - [x] reference any related issues - [ ] updated unit tests - [x] add appropriate label (`enhancement`, `bug`, `breaking`, `dependencies`, `ci`) - [x] ready for review --- pkg/storage/postgres/migrate.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/storage/postgres/migrate.go b/pkg/storage/postgres/migrate.go index 8ab57107d..c0fe38825 100644 --- a/pkg/storage/postgres/migrate.go +++ b/pkg/storage/postgres/migrate.go @@ -156,6 +156,21 @@ var migrations = []func(context.Context, pgx.Tx) error{ } } + return nil + }, + 6: func(ctx context.Context, tx pgx.Tx) error { + // these indices are redundant + for _, q := range []string{ + `DROP INDEX ` + schemaName + `.` + recordsTableName + `_type_idx`, + `DROP INDEX ` + schemaName + `.` + recordChangesTableName + `_version_idx`, + `DROP INDEX ` + schemaName + `.` + recordChangesTableName + `_type_idx`, + } { + _, err := tx.Exec(ctx, q) + if err != nil { + return err + } + } + return nil }, }