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
Fix SkipScan distinct column identification #3345
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3345 +/- ##
==========================================
- Coverage 90.61% 90.60% -0.01%
==========================================
Files 212 212
Lines 35588 35616 +28
==========================================
+ Hits 32248 32271 +23
- Misses 3340 3345 +5
Continue to review full report at Codecov.
|
a37c7b1
to
8f990d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Please check the comments.
bd3d37f
to
dfd28e1
Compare
PG13 removes the msg parameter for convert_tuples_by_name so this patch provides a compatibility macro that abstracts the version differences away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Minor comments about names
tsl/src/nodes/skip_scan/planner.c
Outdated
@@ -83,7 +90,7 @@ skip_scan_plan_create(PlannerInfo *root, RelOptInfo *relopt, CustomPath *best_pa | |||
CustomScan *skip_plan = makeNode(CustomScan); | |||
IndexPath *index_path = path->index_path; | |||
|
|||
OpExpr *op = fix_indexqual(index_path->indexinfo, path->skip_clause, path->distinct_column); | |||
OpExpr *op = fix_indexqual(index_path->indexinfo, path->skip_clause, path->table_attno); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path->index_attno instead of path->table_attno here after mod to fix_indexqual?
tsl/src/nodes/skip_scan/planner.c
Outdated
{ | ||
/* technically our placeholder col > NULL is unsatisfiable, and in some instances | ||
* the planner will realize this and use is as an excuse to remove other quals. | ||
* in order to prevent this, we prepare this qual ourselves. | ||
*/ | ||
|
||
/* fix_indexqual_references */ | ||
int indexcol = get_idx_key(index, distinct_column); | ||
int indexcol = get_idx_key(index, table_attno); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could pass the index_attno directly instead of lookup here. Don't see table_attno being used.
The SkipScan code assumed the first entry in PathKeys would match the distinct column. This is not always true as postgres will remove entries from PathKeys it considers constant leading to SkipScan operating on the wrong column under those circumstances. This did most likely not cause any wrong results as the other constraints for SkipScan to apply still had to be satisfied but resulted in very inefficient query execution for those affected queries. This patch refactors the SkipScan code to use the distinctClause from the Query instead. Fixes #3330
Remove the chunk name completely from output as the name might have different length leading to different output as table headers are adjusted to the length of the field values.
**Bugfixes** * timescale#3279 Add some more randomness to chunk assignment * timescale#3288 Fix failed update with parallel workers * timescale#3300 Improve trigger handling on distributed hypertables * timescale#3304 Remove paths that reference parent relids for compressed chunks * timescale#3305 Fix pull_varnos miscomputation of relids set * timescale#3310 Generate downgrade script * timescale#3314 Fix heap buffer overflow in hypertable expansion * timescale#3317 Fix heap buffer overflow in remote connection cache. * timescale#3327 Make aggregate in caggs fully qualified * timescale#3327 Make aggregates in caggs fully qualified * timescale#3336 Fix pg_init_privs objsubid handling * timescale#3345 Fix SkipScan distinct column identification * timescale#3355 Fix heap buffer overflow when renaming compressed hypertable columns. * timescale#3367 Improve DecompressChunk qual pushdown * timescale#3377 Fix bad use of repalloc **Thanks** * @db-adrian for reporting an issue when accessing cagg view through postgres_fdw * @fncaldas and @pgwhalen for reporting an issue accessing caggs when public is not in search_path * @fvannee, @mglonnro and @ebreijo for reporting an issue with the upgrade script * @fvannee for reporting a performance regression with SkipScan
**Bugfixes** * timescale#3279 Add some more randomness to chunk assignment * timescale#3288 Fix failed update with parallel workers * timescale#3300 Improve trigger handling on distributed hypertables * timescale#3304 Remove paths that reference parent relids for compressed chunks * timescale#3305 Fix pull_varnos miscomputation of relids set * timescale#3310 Generate downgrade script * timescale#3314 Fix heap buffer overflow in hypertable expansion * timescale#3317 Fix heap buffer overflow in remote connection cache. * timescale#3327 Make aggregate in caggs fully qualified * timescale#3327 Make aggregates in caggs fully qualified * timescale#3336 Fix pg_init_privs objsubid handling * timescale#3345 Fix SkipScan distinct column identification * timescale#3355 Fix heap buffer overflow when renaming compressed hypertable columns. * timescale#3367 Improve DecompressChunk qual pushdown * timescale#3377 Fix bad use of repalloc **Thanks** * @db-adrian for reporting an issue when accessing cagg view through postgres_fdw * @fncaldas and @pgwhalen for reporting an issue accessing caggs when public is not in search_path * @fvannee, @mglonnro and @ebreijo for reporting an issue with the upgrade script * @fvannee for reporting a performance regression with SkipScan
**Bugfixes** * timescale#3279 Add some more randomness to chunk assignment * timescale#3288 Fix failed update with parallel workers * timescale#3300 Improve trigger handling on distributed hypertables * timescale#3304 Remove paths that reference parent relids for compressed chunks * timescale#3305 Fix pull_varnos miscomputation of relids set * timescale#3310 Generate downgrade script * timescale#3314 Fix heap buffer overflow in hypertable expansion * timescale#3317 Fix heap buffer overflow in remote connection cache. * timescale#3327 Make aggregate in caggs fully qualified * timescale#3327 Make aggregates in caggs fully qualified * timescale#3336 Fix pg_init_privs objsubid handling * timescale#3345 Fix SkipScan distinct column identification * timescale#3355 Fix heap buffer overflow when renaming compressed hypertable columns. * timescale#3367 Improve DecompressChunk qual pushdown * timescale#3377 Fix bad use of repalloc **Thanks** * @db-adrian for reporting an issue when accessing cagg view through postgres_fdw * @fncaldas and @pgwhalen for reporting an issue accessing caggs when public is not in search_path * @fvannee, @mglonnro and @ebreijo for reporting an issue with the upgrade script * @fvannee for reporting a performance regression with SkipScan
**Bugfixes** * timescale#3279 Add some more randomness to chunk assignment * timescale#3288 Fix failed update with parallel workers * timescale#3300 Improve trigger handling on distributed hypertables * timescale#3304 Remove paths that reference parent relids for compressed chunks * timescale#3305 Fix pull_varnos miscomputation of relids set * timescale#3310 Generate downgrade script * timescale#3314 Fix heap buffer overflow in hypertable expansion * timescale#3317 Fix heap buffer overflow in remote connection cache. * timescale#3327 Make aggregate in caggs fully qualified * timescale#3327 Make aggregates in caggs fully qualified * timescale#3336 Fix pg_init_privs objsubid handling * timescale#3345 Fix SkipScan distinct column identification * timescale#3355 Fix heap buffer overflow when renaming compressed hypertable columns. * timescale#3367 Improve DecompressChunk qual pushdown * timescale#3377 Fix bad use of repalloc **Thanks** * @db-adrian for reporting an issue when accessing cagg view through postgres_fdw * @fncaldas and @pgwhalen for reporting an issue accessing caggs when public is not in search_path * @fvannee, @mglonnro and @ebreijo for reporting an issue with the upgrade script * @fvannee for reporting a performance regression with SkipScan
**Bugfixes** * timescale#3279 Add some more randomness to chunk assignment * timescale#3288 Fix failed update with parallel workers * timescale#3300 Improve trigger handling on distributed hypertables * timescale#3304 Remove paths that reference parent relids for compressed chunks * timescale#3305 Fix pull_varnos miscomputation of relids set * timescale#3310 Generate downgrade script * timescale#3314 Fix heap buffer overflow in hypertable expansion * timescale#3317 Fix heap buffer overflow in remote connection cache. * timescale#3327 Make aggregate in caggs fully qualified * timescale#3327 Make aggregates in caggs fully qualified * timescale#3336 Fix pg_init_privs objsubid handling * timescale#3345 Fix SkipScan distinct column identification * timescale#3355 Fix heap buffer overflow when renaming compressed hypertable columns. * timescale#3367 Improve DecompressChunk qual pushdown * timescale#3377 Fix bad use of repalloc **Thanks** * @db-adrian for reporting an issue when accessing cagg view through postgres_fdw * @fncaldas and @pgwhalen for reporting an issue accessing caggs when public is not in search_path * @fvannee, @mglonnro and @ebreijo for reporting an issue with the upgrade script * @fvannee for reporting a performance regression with SkipScan
**Bugfixes** * timescale#3279 Add some more randomness to chunk assignment * timescale#3288 Fix failed update with parallel workers * timescale#3300 Improve trigger handling on distributed hypertables * timescale#3304 Remove paths that reference parent relids for compressed chunks * timescale#3305 Fix pull_varnos miscomputation of relids set * timescale#3310 Generate downgrade script * timescale#3314 Fix heap buffer overflow in hypertable expansion * timescale#3317 Fix heap buffer overflow in remote connection cache. * timescale#3327 Make aggregate in caggs fully qualified * timescale#3327 Make aggregates in caggs fully qualified * timescale#3336 Fix pg_init_privs objsubid handling * timescale#3345 Fix SkipScan distinct column identification * timescale#3355 Fix heap buffer overflow when renaming compressed hypertable columns. * timescale#3367 Improve DecompressChunk qual pushdown * timescale#3377 Fix bad use of repalloc **Thanks** * @db-adrian for reporting an issue when accessing cagg view through postgres_fdw * @fncaldas and @pgwhalen for reporting an issue accessing caggs when public is not in search_path * @fvannee, @mglonnro and @ebreijo for reporting an issue with the upgrade script * @fvannee for reporting a performance regression with SkipScan
**Bugfixes** * timescale#3279 Add some more randomness to chunk assignment * timescale#3288 Fix failed update with parallel workers * timescale#3300 Improve trigger handling on distributed hypertables * timescale#3304 Remove paths that reference parent relids for compressed chunks * timescale#3305 Fix pull_varnos miscomputation of relids set * timescale#3310 Generate downgrade script * timescale#3314 Fix heap buffer overflow in hypertable expansion * timescale#3317 Fix heap buffer overflow in remote connection cache. * timescale#3327 Make aggregate in caggs fully qualified * timescale#3327 Make aggregates in caggs fully qualified * timescale#3336 Fix pg_init_privs objsubid handling * timescale#3345 Fix SkipScan distinct column identification * timescale#3355 Fix heap buffer overflow when renaming compressed hypertable columns. * timescale#3367 Improve DecompressChunk qual pushdown * timescale#3377 Fix bad use of repalloc **Thanks** * @db-adrian for reporting an issue when accessing cagg view through postgres_fdw * @fncaldas and @pgwhalen for reporting an issue accessing caggs when public is not in search_path * @fvannee, @mglonnro and @ebreijo for reporting an issue with the upgrade script * @fvannee for reporting a performance regression with SkipScan
**Bugfixes** * timescale#3279 Add some more randomness to chunk assignment * timescale#3288 Fix failed update with parallel workers * timescale#3300 Improve trigger handling on distributed hypertables * timescale#3304 Remove paths that reference parent relids for compressed chunks * timescale#3305 Fix pull_varnos miscomputation of relids set * timescale#3310 Generate downgrade script * timescale#3314 Fix heap buffer overflow in hypertable expansion * timescale#3317 Fix heap buffer overflow in remote connection cache. * timescale#3327 Make aggregate in caggs fully qualified * timescale#3327 Make aggregates in caggs fully qualified * timescale#3336 Fix pg_init_privs objsubid handling * timescale#3345 Fix SkipScan distinct column identification * timescale#3355 Fix heap buffer overflow when renaming compressed hypertable columns. * timescale#3367 Improve DecompressChunk qual pushdown * timescale#3377 Fix bad use of repalloc **Thanks** * @db-adrian for reporting an issue when accessing cagg view through postgres_fdw * @fncaldas and @pgwhalen for reporting an issue accessing caggs when public is not in search_path * @fvannee, @mglonnro and @ebreijo for reporting an issue with the upgrade script * @fvannee for reporting a performance regression with SkipScan
**Bugfixes** * #3279 Add some more randomness to chunk assignment * #3288 Fix failed update with parallel workers * #3300 Improve trigger handling on distributed hypertables * #3304 Remove paths that reference parent relids for compressed chunks * #3305 Fix pull_varnos miscomputation of relids set * #3310 Generate downgrade script * #3314 Fix heap buffer overflow in hypertable expansion * #3317 Fix heap buffer overflow in remote connection cache. * #3327 Make aggregate in caggs fully qualified * #3327 Make aggregates in caggs fully qualified * #3336 Fix pg_init_privs objsubid handling * #3345 Fix SkipScan distinct column identification * #3355 Fix heap buffer overflow when renaming compressed hypertable columns. * #3367 Improve DecompressChunk qual pushdown * #3377 Fix bad use of repalloc **Thanks** * @db-adrian for reporting an issue when accessing cagg view through postgres_fdw * @fncaldas and @pgwhalen for reporting an issue accessing caggs when public is not in search_path * @fvannee, @mglonnro and @ebreijo for reporting an issue with the upgrade script * @fvannee for reporting a performance regression with SkipScan
**Bugfixes** * timescale#3279 Add some more randomness to chunk assignment * timescale#3288 Fix failed update with parallel workers * timescale#3300 Improve trigger handling on distributed hypertables * timescale#3304 Remove paths that reference parent relids for compressed chunks * timescale#3305 Fix pull_varnos miscomputation of relids set * timescale#3310 Generate downgrade script * timescale#3314 Fix heap buffer overflow in hypertable expansion * timescale#3317 Fix heap buffer overflow in remote connection cache. * timescale#3327 Make aggregate in caggs fully qualified * timescale#3327 Make aggregates in caggs fully qualified * timescale#3336 Fix pg_init_privs objsubid handling * timescale#3345 Fix SkipScan distinct column identification * timescale#3355 Fix heap buffer overflow when renaming compressed hypertable columns. * timescale#3367 Improve DecompressChunk qual pushdown * timescale#3377 Fix bad use of repalloc **Thanks** * @db-adrian for reporting an issue when accessing cagg view through postgres_fdw * @fncaldas and @pgwhalen for reporting an issue accessing caggs when public is not in search_path * @fvannee, @mglonnro and @ebreijo for reporting an issue with the upgrade script * @fvannee for reporting a performance regression with SkipScan
**Bugfixes** * timescale#3279 Add some more randomness to chunk assignment * timescale#3288 Fix failed update with parallel workers * timescale#3300 Improve trigger handling on distributed hypertables * timescale#3304 Remove paths that reference parent relids for compressed chunks * timescale#3305 Fix pull_varnos miscomputation of relids set * timescale#3310 Generate downgrade script * timescale#3314 Fix heap buffer overflow in hypertable expansion * timescale#3317 Fix heap buffer overflow in remote connection cache. * timescale#3327 Make aggregate in caggs fully qualified * timescale#3327 Make aggregates in caggs fully qualified * timescale#3336 Fix pg_init_privs objsubid handling * timescale#3345 Fix SkipScan distinct column identification * timescale#3355 Fix heap buffer overflow when renaming compressed hypertable columns. * timescale#3367 Improve DecompressChunk qual pushdown * timescale#3377 Fix bad use of repalloc **Thanks** * @db-adrian for reporting an issue when accessing cagg view through postgres_fdw * @fncaldas and @pgwhalen for reporting an issue accessing caggs when public is not in search_path * @fvannee, @mglonnro and @ebreijo for reporting an issue with the upgrade script * @fvannee for reporting a performance regression with SkipScan
**Bugfixes** * timescale#3279 Add some more randomness to chunk assignment * timescale#3288 Fix failed update with parallel workers * timescale#3300 Improve trigger handling on distributed hypertables * timescale#3304 Remove paths that reference parent relids for compressed chunks * timescale#3305 Fix pull_varnos miscomputation of relids set * timescale#3310 Generate downgrade script * timescale#3314 Fix heap buffer overflow in hypertable expansion * timescale#3317 Fix heap buffer overflow in remote connection cache. * timescale#3327 Make aggregate in caggs fully qualified * timescale#3327 Make aggregates in caggs fully qualified * timescale#3336 Fix pg_init_privs objsubid handling * timescale#3345 Fix SkipScan distinct column identification * timescale#3355 Fix heap buffer overflow when renaming compressed hypertable columns. * timescale#3367 Improve DecompressChunk qual pushdown * timescale#3377 Fix bad use of repalloc **Thanks** * @db-adrian for reporting an issue when accessing cagg view through postgres_fdw * @fncaldas and @pgwhalen for reporting an issue accessing caggs when public is not in search_path * @fvannee, @mglonnro and @ebreijo for reporting an issue with the upgrade script * @fvannee for reporting a performance regression with SkipScan
This maintenance release contains bugfixes since the 2.3.0 release. We deem it moderate priority for upgrading. **Bugfixes** * timescale#3279 Add some more randomness to chunk assignment * timescale#3288 Fix failed update with parallel workers * timescale#3300 Improve trigger handling on distributed hypertables * timescale#3304 Remove paths that reference parent relids for compressed chunks * timescale#3305 Fix pull_varnos miscomputation of relids set * timescale#3310 Generate downgrade script * timescale#3314 Fix heap buffer overflow in hypertable expansion * timescale#3317 Fix heap buffer overflow in remote connection cache. * timescale#3327 Make aggregate in caggs fully qualified * timescale#3327 Make aggregates in caggs fully qualified * timescale#3336 Fix pg_init_privs objsubid handling * timescale#3345 Fix SkipScan distinct column identification * timescale#3355 Fix heap buffer overflow when renaming compressed hypertable columns. * timescale#3367 Improve DecompressChunk qual pushdown * timescale#3377 Fix bad use of repalloc **Thanks** * @db-adrian for reporting an issue when accessing cagg view through postgres_fdw * @fncaldas and @pgwhalen for reporting an issue accessing caggs when public is not in search_path * @fvannee, @mglonnro and @ebreijo for reporting an issue with the upgrade script * @fvannee for reporting a performance regression with SkipScan
This maintenance release contains bugfixes since the 2.3.0 release. We deem it moderate priority for upgrading. **Bugfixes** * timescale#3279 Add some more randomness to chunk assignment * timescale#3288 Fix failed update with parallel workers * timescale#3300 Improve trigger handling on distributed hypertables * timescale#3304 Remove paths that reference parent relids for compressed chunks * timescale#3305 Fix pull_varnos miscomputation of relids set * timescale#3310 Generate downgrade script * timescale#3314 Fix heap buffer overflow in hypertable expansion * timescale#3317 Fix heap buffer overflow in remote connection cache. * timescale#3327 Make aggregate in caggs fully qualified * timescale#3327 Make aggregates in caggs fully qualified * timescale#3336 Fix pg_init_privs objsubid handling * timescale#3345 Fix SkipScan distinct column identification * timescale#3355 Fix heap buffer overflow when renaming compressed hypertable columns. * timescale#3367 Improve DecompressChunk qual pushdown * timescale#3377 Fix bad use of repalloc **Thanks** * @db-adrian for reporting an issue when accessing cagg view through postgres_fdw * @fncaldas and @pgwhalen for reporting an issue accessing caggs when public is not in search_path * @fvannee, @mglonnro and @ebreijo for reporting an issue with the upgrade script * @fvannee for reporting a performance regression with SkipScan
This maintenance release contains bugfixes since the 2.3.0 release. We deem it moderate priority for upgrading. The release introduces the possibility of generating downgrade scripts, improves the trigger handling for distributed hypertables, adds some more randomness to chunk assignment to avoid thundering herd issues in chunk assignment, and fixes some issues in update handling as well as some other bugs. **Bugfixes** * timescale#3279 Add some more randomness to chunk assignment * timescale#3288 Fix failed update with parallel workers * timescale#3300 Improve trigger handling on distributed hypertables * timescale#3304 Remove paths that reference parent relids for compressed chunks * timescale#3305 Fix pull_varnos miscomputation of relids set * timescale#3310 Generate downgrade script * timescale#3314 Fix heap buffer overflow in hypertable expansion * timescale#3317 Fix heap buffer overflow in remote connection cache. * timescale#3327 Make aggregate in caggs fully qualified * timescale#3327 Make aggregates in caggs fully qualified * timescale#3336 Fix pg_init_privs objsubid handling * timescale#3345 Fix SkipScan distinct column identification * timescale#3355 Fix heap buffer overflow when renaming compressed hypertable columns. * timescale#3367 Improve DecompressChunk qual pushdown * timescale#3377 Fix bad use of repalloc **Thanks** * @db-adrian for reporting an issue when accessing cagg view through postgres_fdw * @fncaldas and @pgwhalen for reporting an issue accessing caggs when public is not in search_path * @fvannee, @mglonnro and @ebreijo for reporting an issue with the upgrade script * @fvannee for reporting a performance regression with SkipScan
This maintenance release contains bugfixes since the 2.3.0 release. We deem it moderate priority for upgrading. The release introduces the possibility of generating downgrade scripts, improves the trigger handling for distributed hypertables, adds some more randomness to chunk assignment to avoid thundering herd issues in chunk assignment, and fixes some issues in update handling as well as some other bugs. **Bugfixes** * timescale#3279 Add some more randomness to chunk assignment * timescale#3288 Fix failed update with parallel workers * timescale#3300 Improve trigger handling on distributed hypertables * timescale#3304 Remove paths that reference parent relids for compressed chunks * timescale#3305 Fix pull_varnos miscomputation of relids set * timescale#3310 Generate downgrade script * timescale#3314 Fix heap buffer overflow in hypertable expansion * timescale#3317 Fix heap buffer overflow in remote connection cache. * timescale#3327 Make aggregate in caggs fully qualified * timescale#3327 Make aggregates in caggs fully qualified * timescale#3336 Fix pg_init_privs objsubid handling * timescale#3345 Fix SkipScan distinct column identification * timescale#3355 Fix heap buffer overflow when renaming compressed hypertable columns. * timescale#3367 Improve DecompressChunk qual pushdown * timescale#3377 Fix bad use of repalloc **Thanks** * @db-adrian for reporting an issue when accessing cagg view through postgres_fdw * @fncaldas and @pgwhalen for reporting an issue accessing caggs when public is not in search_path * @fvannee, @mglonnro and @ebreijo for reporting an issue with the upgrade script * @fvannee for reporting a performance regression with SkipScan
This maintenance release contains bugfixes since the 2.3.0 release. We deem it moderate priority for upgrading. The release introduces the possibility of generating downgrade scripts, improves the trigger handling for distributed hypertables, adds some more randomness to chunk assignment to avoid thundering herd issues in chunk assignment, and fixes some issues in update handling as well as some other bugs. **Bugfixes** * #3279 Add some more randomness to chunk assignment * #3288 Fix failed update with parallel workers * #3300 Improve trigger handling on distributed hypertables * #3304 Remove paths that reference parent relids for compressed chunks * #3305 Fix pull_varnos miscomputation of relids set * #3310 Generate downgrade script * #3314 Fix heap buffer overflow in hypertable expansion * #3317 Fix heap buffer overflow in remote connection cache. * #3327 Make aggregate in caggs fully qualified * #3327 Make aggregates in caggs fully qualified * #3336 Fix pg_init_privs objsubid handling * #3345 Fix SkipScan distinct column identification * #3355 Fix heap buffer overflow when renaming compressed hypertable columns. * #3367 Improve DecompressChunk qual pushdown * #3377 Fix bad use of repalloc **Thanks** * @db-adrian for reporting an issue when accessing cagg view through postgres_fdw * @fncaldas and @pgwhalen for reporting an issue accessing caggs when public is not in search_path * @fvannee, @mglonnro and @ebreijo for reporting an issue with the upgrade script * @fvannee for reporting a performance regression with SkipScan
The SkipScan code assumed the first entry in PathKeys would match the distinct column. This is not always true as postgres will remove entries from PathKeys it considers constant leading to SkipScan operating on the wrong column under those circumstances. This did most likely not cause any wrong results as the other constraints for SkipScan to apply still had to be satisfied but resulted in very inefficient query execution for those affected
queries.
This patch refactors the SkipScan code to use the distinctClause from the Query instead.
Fixes #3330
Disable-check: commit-count