A reloption for partitioned tables - parallel_workers - Mailing list pgsql-hackers

From Seamus Abshere
Subject A reloption for partitioned tables - parallel_workers
Date
Msg-id 95b1dd96-8634-4545-b1de-e2ac779beb44@www.fastmail.com
Whole thread Raw
Responses Re: A reloption for partitioned tables - parallel_workers
List pgsql-hackers
hi,

It turns out parallel_workers may be a useful reloption for certain uses of partitioned tables, at least if they're
madeup 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
whatthe right format is.
 

Thank you,
Seamus



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Some regular-expression performance hacking
Next
From: Thomas Munro
Date:
Subject: Re: Default wal_sync_method on FreeBSD