Try this:
alter system set max_parallel_workers = 20;
and restart the system.
max_parallel_workers is still 8, according to both SHOW and
pg_controldata, nor can you launch more than 8 workers.
Even odder, if you just do
regression=# set max_parallel_workers = 200;
SET
regression=# show max_parallel_workers;
max_parallel_workers
----------------------
200
(1 row)
which should certainly not happen for a PGC_POSTMASTER parameter.
We seem to have an awful lot of mechanism that's concerned with
adjustments of max_parallel_workers, for something that apparently
might as well be a compile-time #define ... so I assume it's supposed
to be changeable at restart and somebody broke it. But it's not
working as I'd expect in any branch from 10 onwards.
regards, tom lane
If I understand that correctly it works for me.
postgres=# alter system set max_parallel_workers = 1;
$ pg_ctl restart -l log
$ psql postgres
psql (13devel)
postgres=# explain analyze select * from test where b > 1;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------
Gather (cost=1000.00..98294.84 rows=1 width=8) (actual time=1635.959..1636.028 rows=0 loops=1)
Workers Planned: 2
Workers Launched: 1
-> Parallel Seq Scan on test (cost=0.00..97294.74 rows=1 width=8) (actual time=1632.239..1632.239 rows=0 loops=2)
Filter: (b > 1)
Rows Removed by Filter: 5050000
Planning Time: 0.533 ms
Execution Time: 1636.080 ms
(8 rows)
postgres=# alter system set max_parallel_workers = 2;
ALTER SYSTEM
postgres=# \q
vagrant@vagrant:~/percona/postgresql$ pg_ctl restart -l log
vagrant@vagrant:~/percona/postgresql$ psql postgres
psql (13devel)
Type "help" for help.
postgres=# explain analyze select * from test where b > 1;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------
Gather (cost=1000.00..98294.84 rows=1 width=8) (actual time=1622.210..1622.274 rows=0 loops=1)
Workers Planned: 2
Workers Launched: 2
-> Parallel Seq Scan on test (cost=0.00..97294.74 rows=1 width=8) (actual time=1616.000..1616.000 rows=0 loops=3)
Filter: (b > 1)
Rows Removed by Filter: 3366667
Planning Time: 0.699 ms
Execution Time: 1622.325 ms
(8 rows)
--
Ibrar Ahmed