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

Commite415831

Browse files
committed
Mop-up for parallel degree-ectomy.
Fix a couple of overlooked uses of "degree" terminology. Make the parallelworker count selection logic in create_plain_partial_paths more robust (inparticular, it failed with max_parallel_workers_per_gather set to zero).
1 parentc9ce4a1 commite415831

File tree

3 files changed

+26
-29
lines changed

3 files changed

+26
-29
lines changed

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

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -669,27 +669,14 @@ set_plain_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
669669
staticvoid
670670
create_plain_partial_paths(PlannerInfo*root,RelOptInfo*rel)
671671
{
672-
intparallel_workers=1;
672+
intparallel_workers;
673673

674674
/*
675-
* If the user has set the parallel_workers reloption,we decide what to do
676-
*based on the value ofthat option. Otherwise, we estimate a value.
675+
* If the user has set the parallel_workers reloption,use that; otherwise
676+
*select a default number ofworkers.
677677
*/
678678
if (rel->rel_parallel_workers!=-1)
679-
{
680-
/*
681-
* If parallel_workers = 0 is set for this relation, bail out. The
682-
* user does not want a parallel path for this relation.
683-
*/
684-
if (rel->rel_parallel_workers==0)
685-
return;
686-
687-
/*
688-
* Use the table parallel_workers, but don't go further than
689-
* max_parallel_workers_per_gather.
690-
*/
691-
parallel_workers=Min(rel->rel_parallel_workers,max_parallel_workers_per_gather);
692-
}
679+
parallel_workers=rel->rel_parallel_workers;
693680
else
694681
{
695682
intparallel_threshold=1000;
@@ -706,20 +693,29 @@ create_plain_partial_paths(PlannerInfo *root, RelOptInfo *rel)
706693
return;
707694

708695
/*
709-
*Limit thedegree ofparallelism logarithmicallybased on the size
710-
*of therelation. This probably needs to be a good deal more
696+
*Select thenumber ofworkersbased on thelog of thesize of the
697+
* relation. This probably needs to be a good deal more
711698
* sophisticated, but we need something here for now.
712699
*/
713-
while (rel->pages>parallel_threshold*3&&
714-
parallel_workers<max_parallel_workers_per_gather)
700+
parallel_workers=1;
701+
while (rel->pages>parallel_threshold*3)
715702
{
716703
parallel_workers++;
717704
parallel_threshold *=3;
718705
if (parallel_threshold >=PG_INT32_MAX /3)
719-
break;
706+
break;/* avoid overflow */
720707
}
721708
}
722709

710+
/*
711+
* In no case use more than max_parallel_workers_per_gather workers.
712+
*/
713+
parallel_workers=Min(parallel_workers,max_parallel_workers_per_gather);
714+
715+
/* If any limit was set to zero, the user doesn't want a parallel scan. */
716+
if (parallel_workers <=0)
717+
return;
718+
723719
/* Add an unordered partial path based on a parallel sequential scan. */
724720
add_partial_path(rel,create_seqscan_path(root,rel,NULL,parallel_workers));
725721
}

‎src/backend/optimizer/util/plancat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
128128
estimate_rel_size(relation,rel->attr_widths-rel->min_attr,
129129
&rel->pages,&rel->tuples,&rel->allvisfrac);
130130

131-
/*Retrive the parallel_workers reloption,if set. */
132-
rel->rel_parallel_workers=RelationGetParallelDegree(relation,-1);
131+
/*Retrieve the parallel_workers reloption,or -1 if not set. */
132+
rel->rel_parallel_workers=RelationGetParallelWorkers(relation,-1);
133133

134134
/*
135135
* Make list of indexes. Ignore indexes on system catalogs if told to.

‎src/include/utils/rel.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,19 +235,20 @@ typedef struct StdRdOptions
235235
/*
236236
* RelationIsUsedAsCatalogTable
237237
*Returns whether the relation should be treated as a catalog table
238-
*from the pov of logical decoding. Note multiple evalor argument!
238+
*from the pov of logical decoding. Note multiple evalof argument!
239239
*/
240240
#defineRelationIsUsedAsCatalogTable(relation)\
241241
((relation)->rd_options ?\
242242
((StdRdOptions *) (relation)->rd_options)->user_catalog_table : false)
243243

244244
/*
245-
* RelationGetParallelDegree
246-
*Returns the relation's parallel_workers. Note multiple eval of argument!
245+
* RelationGetParallelWorkers
246+
*Returns the relation's parallel_workers reloption setting.
247+
*Note multiple eval of argument!
247248
*/
248-
#defineRelationGetParallelDegree(relation,defaultpd) \
249+
#defineRelationGetParallelWorkers(relation,defaultpw) \
249250
((relation)->rd_options ? \
250-
((StdRdOptions *) (relation)->rd_options)->parallel_workers : (defaultpd))
251+
((StdRdOptions *) (relation)->rd_options)->parallel_workers : (defaultpw))
251252

252253

253254
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp