Don't use ctid scan for negative relpages (like during scanning a partitioned table).#435
Merged
staticlibs merged 2 commits intoduckdb:mainfrom Apr 12, 2026
Merged
Conversation
Scanning a partitioned table caused an infinite hang because PostgreSQL sets relpages=-1 for relkind='p' tables. Cast to idx_t (uint64) gives pages_approx = 2^64-1, so the scanner loops over ~18 quintillion pages. Now throws NotImplementedException at bind time with a message that includes the relation kind and table name.
simi
commented
Apr 11, 2026
simi
commented
Apr 11, 2026
simi
commented
Apr 11, 2026
Contributor
Author
|
I'll check on CI failures. |
Collaborator
|
Just FYI, some details on local test runs: #431 (comment) |
- fixes hanging partitioned table scan for now
Contributor
Author
|
@staticlibs thanks for the hint, by mistake I have run only new tests before submitting PR. Clearly this should not break |
simi
commented
Apr 12, 2026
staticlibs
approved these changes
Apr 12, 2026
Collaborator
staticlibs
left a comment
There was a problem hiding this comment.
Thanks! Looks good to me.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Scanning a partitioned table caused an infinite hang because PostgreSQL sets relpages=-1 for relkind='p' tables. Cast to idx_t (uint64) gives pages_approx = 2^64-1, so the scanner loops over ~18 quintillion pages.
Now throws NotImplementedException at bind time with a message that includes the relation kind and table name.Now fallback to 0 estimate as scanner already does in few other cases. Keep original relpages value (idx_tneeds to be "downgraded" toint64_tto be able to hold original -1 value) inapprox_num_pagesand later during preparing scan, check for negativeapprox_num_pagesand fallback touse_ctid_scan = falsefor now.Initial step to provide support for partitioned tables, since those are broken as reported at #220.
I have plan to open set of smaller PRs to improve the situation ending with full support of partitioned tables. This is initial foundation - accepting the broken state and fallback to slower but working scan.
Example EXPLAIN (SELECT hangs):
pg_classreturns