-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: recreate account index concurrently
- Loading branch information
Showing
5 changed files
with
89 additions
and
36 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
internal/storage/bucket/migrations/19-accounts-recreate-unique-index/notes.yaml
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 @@ | ||
name: Recreate accounts unique index |
9 changes: 9 additions & 0 deletions
9
internal/storage/bucket/migrations/19-accounts-recreate-unique-index/up.sql
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,9 @@ | ||
-- There is already a covering index on accounts table (including seq column). | ||
-- As we will remove the seq column in next migration, we have to create a new index without it (PG will remove it automatically in background). | ||
-- Also, we create the index concurrently to avoid locking the table. | ||
-- And, as there is already an index on this table, the index creation should not fail. | ||
-- | ||
-- We create this index in a dedicated as, as the doc mentions it (https://www.postgresql.org/docs/current/protocol-flow.html#PROTOCOL-FLOW-MULTI-STATEMENT) | ||
-- multi statements queries are automatically wrapped inside transaction block, and it's forbidden | ||
-- to create index concurrently inside a transaction block. | ||
create unique index concurrently accounts_ledger2 on "{{.Bucket}}".accounts (ledger, address) |
File renamed without changes.
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
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