-
Notifications
You must be signed in to change notification settings - Fork 57
fix: normalize partial index IN-list predicates to avoid perpetual rebuild (#473) #491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
Empty file.
15 changes: 15 additions & 0 deletions
15
testdata/diff/create_index/issue_473_partial_index_in_list/new.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| CREATE TABLE findings ( | ||
| id uuid PRIMARY KEY, | ||
| org_id uuid NOT NULL, | ||
| status varchar(20) NOT NULL, | ||
| impact_score int | ||
| ); | ||
|
|
||
| -- Same partial index, but written in the form that pgschema dump renders | ||
| -- (copied from pg_get_indexdef). When re-parsed, PostgreSQL stores it with an | ||
| -- element-level cast: "= ANY (ARRAY[('x'::varchar)::text, ...])". This is | ||
| -- semantically identical to the IN-list form in old.sql, so the diff must be | ||
| -- empty - no spurious concurrent rebuild (issue #473). | ||
| CREATE INDEX idx_finding_actionable | ||
| ON findings (org_id, status, impact_score DESC) | ||
| WHERE (status)::text = ANY ((ARRAY['new'::character varying, 'acknowledged'::character varying])::text[]); |
12 changes: 12 additions & 0 deletions
12
testdata/diff/create_index/issue_473_partial_index_in_list/old.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| CREATE TABLE findings ( | ||
| id uuid PRIMARY KEY, | ||
| org_id uuid NOT NULL, | ||
| status varchar(20) NOT NULL, | ||
| impact_score int | ||
| ); | ||
|
|
||
| -- Partial index written with a natural IN-list predicate. PostgreSQL stores | ||
| -- this in the catalog with an array-level cast: "= ANY ((ARRAY[...])::text[])". | ||
| CREATE INDEX idx_finding_actionable | ||
| ON findings (org_id, status, impact_score DESC) | ||
| WHERE status IN ('new', 'acknowledged'); |
9 changes: 9 additions & 0 deletions
9
testdata/diff/create_index/issue_473_partial_index_in_list/plan.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "version": "1.0.0", | ||
| "pgschema_version": "1.11.1", | ||
| "created_at": "1970-01-01T00:00:00Z", | ||
| "source_fingerprint": { | ||
| "hash": "ee04b3107ba14c3c5811bc73d23ffc1e8422ceea20a6e5a129c3c3eca7979ef0" | ||
| }, | ||
| "groups": null | ||
| } |
Empty file.
1 change: 1 addition & 0 deletions
1
testdata/diff/create_index/issue_473_partial_index_in_list/plan.txt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| No changes detected. |
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.
Uh oh!
There was an error while loading. Please reload this page.