hi,
It turns out parallel_workers may be a useful reloption for certain uses of
partitioned tables, at least if they're made up of fancy column store
partitions (see
https://www.postgresql.org/message-id/7d6fdc20-857c-4cbe-ae2e-c0ff9520ed55%40www.fastmail.com).
Would somebody tell me what I'm doing wrong? I would love to submit a patch but
I'm stuck:
diff --git a/src/backend/optimizer/path/allpaths.c
b/src/backend/optimizer/path/allpaths.c
index cd3fdd259c..f1ade035ac 100644
--- a/src/backend/optimizer/path/allpaths.c
+++ b/src/backend/optimizer/path/allpaths.c
@@ -3751,6 +3751,7 @@ compute_parallel_worker(RelOptInfo *rel, double
heap_pages, double index_pages,
* If the user has set the parallel_workers reloption, use that;
otherwise
* select a default number of workers.
*/
+ // I want to affect this
if (rel->rel_parallel_workers != -1)
parallel_workers = rel->rel_parallel_workers;
else
so I do this
diff --git a/src/backend/access/common/reloptions.c
b/src/backend/access/common/reloptions.c
index c687d3ee9e..597b209bfb 100644
--- a/src/backend/access/common/reloptions.c
+++ b/src/backend/access/common/reloptions.c
@@ -1961,13 +1961,15 @@ build_local_reloptions(local_relopts *relopts, Datum
options, bool validate)
bytea *
partitioned_table_reloptions(Datum reloptions, bool validate)
{
- /*
- * There are no options for partitioned tables yet, but this is able to
do
- * some validation.
- */
+ static const relopt_parse_elt tab[] = {
+ {"parallel_workers", RELOPT_TYPE_INT,
+ offsetof(StdRdOptions, parallel_workers)},
+ };
+
return (bytea *) build_reloptions(reloptions, validate,
RELOPT_KIND_PARTITIONED,
- 0,
NULL, 0);
+
sizeof(StdRdOptions),
+ tab,
lengthof(tab));
}
That "works":
postgres=# alter table test_3pd_cstore_partitioned set (parallel_workers = 33);
ALTER TABLE
postgres=# select relname, relkind, reloptions from pg_class where relname =
'test_3pd_cstore_partitioned';
relname | relkind | reloptions
-----------------------------+---------+-----------------------
test_3pd_cstore_partitioned | p | {parallel_workers=33}
(1 row)
But it seems to be ignored:
diff --git a/src/backend/optimizer/path/allpaths.c
b/src/backend/optimizer/path/allpaths.c
index cd3fdd259c..c68835ce38 100644
--- a/src/backend/optimizer/path/allpaths.c
+++ b/src/backend/optimizer/path/allpaths.c
@@ -3751,6 +3751,8 @@ compute_parallel_worker(RelOptInfo *rel, double
heap_pages, double index_pages,
* If the user has set the parallel_workers reloption, use that;
otherwise
* select a default number of workers.
*/
+ // I want to affect this, but this assertion always passes
+ Assert(rel->rel_parallel_workers == -1)
if (rel->rel_parallel_workers != -1)
parallel_workers = rel->rel_parallel_workers;
else
Thanks and please forgive my code pasting etiquette as this is my first post to
pgsql-hackers and I'm not quite sure what the right format is.
Thank you,
Seamus