8000 Support Parallel Append plan nodes. · postgrespro/postgres@ab72716 · GitHub
[go: up one dir, main page]

Skip to content

Commit ab72716

Browse files
committed
Support Parallel Append plan nodes.
When we create an Append node, we can spread out the workers over the subplans instead of piling on to each subplan one at a time, which should typically be a bit more efficient, both because the startup cost of any plan executed entirely by one worker is paid only once and also because of reduced contention. We can also construct Append plans using a mix of partial and non-partial subplans, which may allow for parallelism in places that otherwise couldn't support it. Unfortunately, this patch doesn't handle the important case of parallelizing UNION ALL by running each branch in a separate worker; the executor infrastructure is added here, but more planner work is needed. Amit Khandekar, Robert Haas, Amul Sul, reviewed and tested by Ashutosh Bapat, Amit Langote, Rafia Sabih, Amit Kapila, and Rajkumar Raghuwanshi. Discussion: http://postgr.es/m/CAJ3gD9dy0K_E8r727heqXoBmWZ83HwLFwdcaSSmBQ1+S+vRuUQ@mail.gmail.com
1 parent 8097d18 commit ab72716

File tree

31 files changed

+959
-129
lines changed
  • utils/misc
  • include
  • test/regress
  • 31 files changed

    +959
    -129
    lines changed

    doc/src/sgml/config.sgml

    Lines changed: 14 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -3633,6 +3633,20 @@ ANY <replaceable class="parameter">num_sync</replaceable> ( <replaceable class="
    36333633
    </listitem>
    36343634
    </varlistentry>
    36353635

    3636+
    <varlistentry id="guc-enable-parallel-append" xreflabel="enable_parallel_append">
    3637+
    <term><varname>enable_parallel_append</varname> (<type>boolean</type>)
    3638+
    <indexterm>
    3639+
    <primary><varname>enable_parallel_append</> configuration parameter</primary>
    3640+
    </indexterm>
    3641+
    </term>
    3642+
    <listitem>
    3643+
    <para>
    3644+
    Enables or disables the query planner's use of parallel-aware
    3645+
    append plan types. The default is <literal>on</>.
    3646+
    </para>
    3647+
    </listitem>
    3648+
    </varlistentry>
    3649+
    36363650
    <varlistentry id="guc-enable-partition-wise-join" xreflabel="enable_partition_wise_join">
    36373651
    <term><varname>enable_partition_wise_join</varname> (<type>boolean</type>)
    36383652
    <indexterm>

    doc/src/sgml/monitoring.sgml

    Lines changed: 6 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -845,7 +845,7 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
    845845

    846846
    <tbody>
    847847
    <row>
    848-
    <entry morerows="62"><literal>LWLock</literal></entry>
    848+
    <entry morerows="63"><literal>LWLock</literal></entry>
    849849
    <entry><literal>ShmemIndexLock</literal></entry>
    850850
    <entry>Waiting to find or allocate space in shared memory.</entry>
    851851
    </row>
    @@ -1116,6 +1116,11 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
    11161116
    <entry><literal>tbm</literal></entry>
    11171117
    <entry>Waiting for TBM shared iterator lock.</entry>
    11181118
    </row>
    1119+
    <row>
    1120+
    <entry><literal>parallel_append</literal></entry>
    1121+
    <entry>Waiting to choose the next subplan during Parallel Append plan
    1122+
    execution.</entry>
    1123+
    </row>
    11191124
    <row>
    11201125
    <entry morerows="9"><literal>Lock</literal></entry>
    11211126
    <entry><literal>relation</literal></entry>

    src/backend/executor/execParallel.c

    Lines changed: 19 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -26,6 +26,7 @@
    2626
    #include "executor/execExpr.h"
    2727
    #include "executor/execParallel.h"
    2828
    #include "executor/executor.h"
    29+
    #include "executor/nodeAppend.h"
    2930
    #include "executor/nodeBitmapHeapscan.h"
    3031
    #include "executor/nodeCustom.h"
    3132
    #include "executor/nodeForeignscan.h"
    @@ -250,6 +251,11 @@ ExecParallelEstimate(PlanState *planstate, ExecParallelEstimateContext *e)
    250251
    ExecForeignScanEstimate((ForeignScanState *) planstate,
    251252
    e->pcxt);
    252253
    break;
    254+
    case T_AppendState:
    255+
    if (planstate->plan->parallel_aware)
    256+
    ExecAppendEstimate((AppendState *) planstate,
    257+
    e->pcxt);
    258+
    break;
    253259
    case T_CustomScanState:
    254260
    if (planstate->plan->parallel_aware)
    255261
    ExecCustomScanEstimate((CustomScanState *) planstate,
    @@ -453,6 +459,11 @@ ExecParallelInitializeDSM(PlanState *planstate,
    453459
    ExecForeignScanInitializeDSM((ForeignScanState *) planstate,
    454460
    d->pcxt);
    455461
    break;
    462+
    case T_AppendState:
    463+
    if (planstate->plan->parallel_aware)
    464+
    ExecAppendInitializeDSM((AppendState *) planstate,
    465+
    d->pcxt);
    466+
    break;
    456467
    case T_CustomScanState:
    457468
    if (planstate->plan->parallel_aware)
    458469
    ExecCustomScanInitializeDSM((CustomScanState *) planstate,
    @@ -884,6 +895,10 @@ ExecParallelReInitializeDSM(PlanState *planstate,
    884895
    ExecForeignScanReInitializeDSM((ForeignScanState *) planstate,
    885896
    pcxt);
    886897
    break;
    898+
    case T_AppendState:
    899+
    if (planstate->plan->parallel_aware)
    900+
    ExecAppendReInitializeDSM((AppendState *) planstate, pcxt);
    901+
    break;
    887902
    case T_CustomScanState:
    888903
    if (planstate->plan->parallel_aware)
    889904
    ExecCustomScanReInitializeDSM((CustomScanState *) planstate,
    @@ -1194,6 +1209,10 @@ ExecParallelInitializeWorker(PlanState *planstate, ParallelWorkerContext *pwcxt)
    11941209
    ExecForeignScanInitializeWorker((ForeignScanState *) planstate,
    11951210
    pwcxt);
    11961211
    break;
    1212+
    case T_AppendState:
    1213+
    if (planstate->plan->parallel_aware)
    1214+
    ExecAppendInitializeWorker((AppendState *) planstate, pwcxt);
    1215+
    break;
    11971216
    case T_CustomScanState:
    11981217
    if (planstate->plan->parallel_aware)
    11991218
    ExecCustomScanInitializeWorker((CustomScanState *) planstate,

    0 commit comments

    Comments
     (0)
    0