Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit75be664

Browse files
committed
Invent min_parallel_relation_size GUC to replace a hard-wired constant.
The main point of doing this is to allow the cutoff to be set very small,even zero, to allow parallel-query behavior to be tested on relativelysmall tables such as we typically use in the regression tests. But itmight be of use to users too. The number-of-workers scaling behavior increate_plain_partial_paths() is pretty ad-hoc and subject to change, sowe won't expose anything about that, but the notion of not consideringparallel query at all for tables below size X seems reasonably stable.Amit Kapila, per a suggestion from meDiscussion: <17170.1465830165@sss.pgh.pa.us>
1 parent3b5a2a8 commit75be664

File tree

5 files changed

+37
-5
lines changed

5 files changed

+37
-5
lines changed

‎doc/src/sgml/config.sgml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3699,6 +3699,20 @@ include_dir 'conf.d'
36993699
</listitem>
37003700
</varlistentry>
37013701

3702+
<varlistentry id="guc-min-parallel-relation-size" xreflabel="min_parallel_relation_size">
3703+
<term><varname>min_parallel_relation_size</varname> (<type>integer</type>)
3704+
<indexterm>
3705+
<primary><varname>min_parallel_relation_size</> configuration parameter</primary>
3706+
</indexterm>
3707+
</term>
3708+
<listitem>
3709+
<para>
3710+
Sets the minimum size of relations to be considered for parallel scan.
3711+
The default is 8 megabytes (<literal>8MB</>).
3712+
</para>
3713+
</listitem>
3714+
</varlistentry>
3715+
37023716
<varlistentry id="guc-effective-cache-size" xreflabel="effective_cache_size">
37033717
<term><varname>effective_cache_size</varname> (<type>integer</type>)
37043718
<indexterm>

‎src/backend/optimizer/path/allpaths.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include"postgres.h"
1717

18+
#include<limits.h>
1819
#include<math.h>
1920

2021
#include"access/sysattr.h"
@@ -56,6 +57,7 @@ typedef struct pushdown_safety_info
5657
/* These parameters are set by GUC */
5758
boolenable_geqo= false;/* just in case GUC doesn't set it */
5859
intgeqo_threshold;
60+
intmin_parallel_relation_size;
5961

6062
/* Hook for plugins to get control in set_rel_pathlist() */
6163
set_rel_pathlist_hook_typeset_rel_pathlist_hook=NULL;
@@ -690,7 +692,7 @@ create_plain_partial_paths(PlannerInfo *root, RelOptInfo *rel)
690692
parallel_workers=rel->rel_parallel_workers;
691693
else
692694
{
693-
intparallel_threshold=1000;
695+
intparallel_threshold;
694696

695697
/*
696698
* If this relation is too small to be worth a parallel scan, just
@@ -699,21 +701,24 @@ create_plain_partial_paths(PlannerInfo *root, RelOptInfo *rel)
699701
* might not be worthwhile just for this relation, but when combined
700702
* with all of its inheritance siblings it may well pay off.
701703
*/
702-
if (rel->pages<parallel_threshold&&
704+
if (rel->pages<(BlockNumber)min_parallel_relation_size&&
703705
rel->reloptkind==RELOPT_BASEREL)
704706
return;
705707

706708
/*
707709
* Select the number of workers based on the log of the size of the
708710
* relation. This probably needs to be a good deal more
709-
* sophisticated, but we need something here for now.
711+
* sophisticated, but we need something here for now. Note that the
712+
* upper limit of the min_parallel_relation_size GUC is chosen to
713+
* prevent overflow here.
710714
*/
711715
parallel_workers=1;
712-
while (rel->pages>parallel_threshold*3)
716+
parallel_threshold=Max(min_parallel_relation_size,1);
717+
while (rel->pages >= (BlockNumber) (parallel_threshold*3))
713718
{
714719
parallel_workers++;
715720
parallel_threshold *=3;
716-
if (parallel_threshold >=PG_INT32_MAX /3)
721+
if (parallel_threshold>INT_MAX /3)
717722
break;/* avoid overflow */
718723
}
719724
}

‎src/backend/utils/misc/guc.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2747,6 +2747,17 @@ static struct config_int ConfigureNamesInt[] =
27472747
NULL,NULL,NULL
27482748
},
27492749

2750+
{
2751+
{"min_parallel_relation_size",PGC_USERSET,QUERY_TUNING_COST,
2752+
gettext_noop("Sets the minimum size of relations to be considered for parallel scan."),
2753+
NULL,
2754+
GUC_UNIT_BLOCKS,
2755+
},
2756+
&min_parallel_relation_size,
2757+
1024,0,INT_MAX /3,
2758+
NULL,NULL,NULL
2759+
},
2760+
27502761
{
27512762
/* Can't be set in postgresql.conf */
27522763
{"server_version_num",PGC_INTERNAL,PRESET_OPTIONS,

‎src/backend/utils/misc/postgresql.conf.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@
304304
#cpu_operator_cost = 0.0025# same scale as above
305305
#parallel_tuple_cost = 0.1# same scale as above
306306
#parallel_setup_cost = 1000.0# same scale as above
307+
#min_parallel_relation_size = 8MB
307308
#effective_cache_size = 4GB
308309

309310
# - Genetic Query Optimizer -

‎src/include/optimizer/paths.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
*/
2323
externboolenable_geqo;
2424
externintgeqo_threshold;
25+
externintmin_parallel_relation_size;
2526

2627
/* Hook for plugins to get control in set_rel_pathlist() */
2728
typedefvoid (*set_rel_pathlist_hook_type) (PlannerInfo*root,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp