diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index e0e5a1e..f3a9780 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -3698,6 +3698,20 @@ include_dir 'conf.d'
+
+
+ min_parallel_relation_size (integer)
+
+ min_parallel_relation_size> configuration parameter
+
+
+
+
+ Sets the minimum size of the relation that can be considered for
+ parallel scan. The default is 8 megabytes (8MB>).
+
+
+
effective_cache_size (integer)
diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c
index cc8ba61..fd58efe 100644
--- a/src/backend/optimizer/path/allpaths.c
+++ b/src/backend/optimizer/path/allpaths.c
@@ -57,6 +57,8 @@ typedef struct pushdown_safety_info
bool enable_geqo = false; /* just in case GUC doesn't set it */
int geqo_threshold;
+int min_parallel_relation_size = DEFAULT_MIN_PARALLEL_RELATION_SIZE;
+
/* Hook for plugins to get control in set_rel_pathlist() */
set_rel_pathlist_hook_type set_rel_pathlist_hook = NULL;
@@ -690,7 +692,7 @@ create_plain_partial_paths(PlannerInfo *root, RelOptInfo *rel)
parallel_workers = rel->rel_parallel_workers;
else
{
- int parallel_threshold = 1000;
+ int parallel_threshold = min_parallel_relation_size;
/*
* If this relation is too small to be worth a parallel scan, just
@@ -713,7 +715,7 @@ create_plain_partial_paths(PlannerInfo *root, RelOptInfo *rel)
{
parallel_workers++;
parallel_threshold *= 3;
- if (parallel_threshold >= PG_INT32_MAX / 3)
+ if (parallel_threshold >= INT_MAX / 3)
break; /* avoid overflow */
}
}
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 9b02111..34b4b02 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2735,6 +2735,17 @@ static struct config_int ConfigureNamesInt[] =
},
{
+ {"min_parallel_relation_size", PGC_USERSET, QUERY_TUNING_COST,
+ gettext_noop("Sets the minimum size of the relation that can be considered for parallel scan."),
+ NULL,
+ GUC_UNIT_BLOCKS,
+ },
+ &min_parallel_relation_size,
+ DEFAULT_MIN_PARALLEL_RELATION_SIZE, 1, INT_MAX / 3,
+ NULL, NULL, NULL
+ },
+
+ {
{"effective_cache_size", PGC_USERSET, QUERY_TUNING_COST,
gettext_noop("Sets the planner's assumption about the size of the disk cache."),
gettext_noop("That is, the portion of the kernel's disk cache that "
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index 8260e37..3fa0540 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -304,6 +304,7 @@
#cpu_operator_cost = 0.0025 # same scale as above
#parallel_tuple_cost = 0.1 # same scale as above
#parallel_setup_cost = 1000.0 # same scale as above
+#min_parallel_relation_size = 8MB
#effective_cache_size = 4GB
# - Genetic Query Optimizer -
diff --git a/src/include/optimizer/paths.h b/src/include/optimizer/paths.h
index f3b25e2..4b3bdca 100644
--- a/src/include/optimizer/paths.h
+++ b/src/include/optimizer/paths.h
@@ -20,8 +20,11 @@
/*
* allpaths.c
*/
+#define DEFAULT_MIN_PARALLEL_RELATION_SIZE 1024 /* measured in pages */
+
extern bool enable_geqo;
extern int geqo_threshold;
+extern int min_parallel_relation_size;
/* Hook for plugins to get control in set_rel_pathlist() */
typedef void (*set_rel_pathlist_hook_type) (PlannerInfo *root,