From: | "Seamus Abshere" <seamus(at)abshere(dot)net> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | A reloption for partitioned tables - parallel_workers |
Date: | 2021-02-15 03:15:04 |
Message-ID: | 95b1dd96-8634-4545-b1de-e2ac779beb44@www.fastmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Munro | 2021-02-15 03:28:08 | Re: Default wal_sync_method on FreeBSD |
Previous Message | Tom Lane | 2021-02-15 03:11:37 | Re: Some regular-expression performance hacking |