diff options
author | Robert Haas <rhaas@postgresql.org> | 2017-08-29 13:12:23 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2017-08-29 13:16:55 -0400 |
commit | 3452dc5240da43e833118484e1e9b4894d04431c (patch) | |
tree | d158d5d9630d80bc8a5ca838ba76eede60c77ba9 /src/backend/executor/nodeGatherMerge.c | |
parent | ce5dcf54b942a469194ae390730f803b3f3fb928 (diff) | |
download | postgresql-3452dc5240da43e833118484e1e9b4894d04431c.tar.gz postgresql-3452dc5240da43e833118484e1e9b4894d04431c.zip |
Push tuple limits through Gather and Gather Merge.
If we only need, say, 10 tuples in total, then we certainly don't need
more than 10 tuples from any single process. Pushing down the limit
lets workers exit early when possible. For Gather Merge, there is
an additional benefit: a Sort immediately below the Gather Merge can
be done as a bounded sort if there is an applicable limit.
Robert Haas and Tom Lane
Discussion: http://postgr.es/m/CA+TgmoYa3QKKrLj5rX7UvGqhH73G1Li4B-EKxrmASaca2tFu9Q@mail.gmail.com
Diffstat (limited to 'src/backend/executor/nodeGatherMerge.c')
-rw-r--r-- | src/backend/executor/nodeGatherMerge.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/backend/executor/nodeGatherMerge.c b/src/backend/executor/nodeGatherMerge.c index 64c62398bbe..2526c584fd0 100644 --- a/src/backend/executor/nodeGatherMerge.c +++ b/src/backend/executor/nodeGatherMerge.c @@ -77,6 +77,7 @@ ExecInitGatherMerge(GatherMerge *node, EState *estate, int eflags) gm_state->ps.plan = (Plan *) node; gm_state->ps.state = estate; gm_state->ps.ExecProcNode = ExecGatherMerge; + gm_state->tuples_needed = -1; /* * Miscellaneous initialization @@ -190,7 +191,8 @@ ExecGatherMerge(PlanState *pstate) if (!node->pei) node->pei = ExecInitParallelPlan(node->ps.lefttree, estate, - gm->num_workers); + gm->num_workers, + node->tuples_needed); /* Try to launch workers. */ pcxt = node->pei->pcxt; |