-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing index for GC in Postgres
- Loading branch information
1 parent
49d31c6
commit a7a1c2d
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
internal/datastore/postgres/migrations/zz_migration.0023_add_missing_gc_index.go
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package migrations | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/jackc/pgx/v5" | ||
) | ||
|
||
const addGCIndexForRelationTupleTransaction = `CREATE INDEX CONCURRENTLY | ||
IF NOT EXISTS ix_relation_tuple_transaction_xid_desc_timestamp | ||
ON relation_tuple_transaction (xid DESC, timestamp);` | ||
|
||
func init() { | ||
if err := DatabaseMigrations.Register("add-missing-gc-index", "add-gc-lock-table", | ||
func(ctx context.Context, conn *pgx.Conn) error { | ||
if _, err := conn.Exec(ctx, addGCIndexForRelationTupleTransaction); err != nil { | ||
return fmt.Errorf("failed to add missing GC index: %w", err) | ||
} | ||
return nil | ||
}, | ||
noTxMigration); err != nil { | ||
panic("failed to register migration: " + err.Error()) | ||
} | ||
} |