On 18/03/2016 00:56, Tom Lane wrote: > Julien Rouhaud <julien.rouh...@dalibo.com> writes: >> Shouldn't we also check "parallel_degree < max_worker_process" ? > >> There's no need to compute any further than that. I think the best fix >> would be to add a CheckHook or AssignHook on max_parallel_degree GUC to >> make sure it's not more than max_worker_process. > > Please, let's not go there. Interdependent checks on GUC values are far > harder to get right than you think. It's far better to design the GUC > specifications so that it doesn't matter. > > For an example whereof I speak, check the sordid history of commit > ee1e5662d8d83307 ("Auto-tune effective_cache size to be 4x shared > buffers"), which eventually got reverted after a huge amount of thrashing > trying to make it work consistently. Admittedly, that was trying to make > the default value of GUC X depend on GUC Y, but I think checking whether > X <= Y would have many of the same problems. The core issue is you don't > know which one's going to get set first. >
Oh, I wasn't aware of that, thanks for the pointer. > In this particular case I think it'd be fine to document that the > effective amount of parallelism is Min(parallel_degree,max_worker_process). > > regards, tom lane > I just saw that it's already documented that way. I attach a patch that makes sure we don't try to compute a parallel_degree beyond this limit (if you think it's worth it), and a missing description and "change requires restart" for the max_worker_processes parameter in postgresql.conf.sample. -- Julien Rouhaud http://dalibo.com - http://dalibo.org
diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c index 4f60b85..2886219 100644 --- a/src/backend/optimizer/path/allpaths.c +++ b/src/backend/optimizer/path/allpaths.c @@ -23,6 +23,7 @@ #include "catalog/pg_operator.h" #include "catalog/pg_proc.h" #include "foreign/fdwapi.h" +#include "miscadmin.h" #include "nodes/makefuncs.h" #include "nodes/nodeFuncs.h" #ifdef OPTIMIZER_DEBUG @@ -678,7 +679,7 @@ create_parallel_paths(PlannerInfo *root, RelOptInfo *rel) * need something here for now. */ while (rel->pages > parallel_threshold * 3 && - parallel_degree < max_parallel_degree) + parallel_degree < Min(max_parallel_degree, max_worker_processes)) { parallel_degree++; parallel_threshold *= 3; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 773b4e8..00368bb 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -163,7 +163,8 @@ # - Asynchronous Behavior - #effective_io_concurrency = 1 # 1-1000; 0 disables prefetching -#max_worker_processes = 8 +#max_worker_processes = 8 # max number of background workers + #(change requires restart) #max_parallel_degree = 0 # max number of worker processes per node
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers