diff options
author | Robert Haas <rhaas@postgresql.org> | 2016-06-06 14:52:58 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2016-06-06 14:52:58 -0400 |
commit | c6dbf1fe79287291bc260cbc06b0de419d2a198c (patch) | |
tree | 8edc5d8f7d13201c73d90f0c217f6e00a27e5099 /src/backend/access/common/printtup.c | |
parent | 44339b892a04e94bbb472235882dc6f7023bdc65 (diff) | |
download | postgresql-c6dbf1fe79287291bc260cbc06b0de419d2a198c.tar.gz postgresql-c6dbf1fe79287291bc260cbc06b0de419d2a198c.zip |
Stop the executor if no more tuples can be sent from worker to leader.
If a Gather node has read as many tuples as it needs (for example, due
to Limit) it may detach the queue connecting it to the worker before
reading all of the worker's tuples. Rather than let the worker
continue to generate and send all of the results, have it stop after
sending the next tuple.
More could be done here to stop the worker even quicker, but this is
about as well as we can hope to do for 9.6.
This is in response to a problem report from Andreas Seltenreich.
Commit 44339b892a04e94bbb472235882dc6f7023bdc65 should be actually be
sufficient to fix that example even without this change, but it seems
better to do this, too, since we might otherwise waste quite a large
amount of effort in one or more workers.
Discussion: CAA4eK1KOKGqmz9bGu+Z42qhRwMbm4R5rfnqsLCNqFs9j14jzEA@mail.gmail.com
Amit Kapila
Diffstat (limited to 'src/backend/access/common/printtup.c')
-rw-r--r-- | src/backend/access/common/printtup.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 1939ff5155b..d9664aa6c6b 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -26,9 +26,9 @@ static void printtup_startup(DestReceiver *self, int operation, TupleDesc typeinfo); -static void printtup(TupleTableSlot *slot, DestReceiver *self); -static void printtup_20(TupleTableSlot *slot, DestReceiver *self); -static void printtup_internal_20(TupleTableSlot *slot, DestReceiver *self); +static bool printtup(TupleTableSlot *slot, DestReceiver *self); +static bool printtup_20(TupleTableSlot *slot, DestReceiver *self); +static bool printtup_internal_20(TupleTableSlot *slot, DestReceiver *self); static void printtup_shutdown(DestReceiver *self); static void printtup_destroy(DestReceiver *self); @@ -299,7 +299,7 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) * printtup --- print a tuple in protocol 3.0 * ---------------- */ -static void +static bool printtup(TupleTableSlot *slot, DestReceiver *self) { TupleDesc typeinfo = slot->tts_tupleDescriptor; @@ -376,13 +376,15 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Return to caller's context, and flush row's temporary memory */ MemoryContextSwitchTo(oldcontext); MemoryContextReset(myState->tmpcontext); + + return true; } /* ---------------- * printtup_20 --- print a tuple in protocol 2.0 * ---------------- */ -static void +static bool printtup_20(TupleTableSlot *slot, DestReceiver *self) { TupleDesc typeinfo = slot->tts_tupleDescriptor; @@ -452,6 +454,8 @@ printtup_20(TupleTableSlot *slot, DestReceiver *self) /* Return to caller's context, and flush row's temporary memory */ MemoryContextSwitchTo(oldcontext); MemoryContextReset(myState->tmpcontext); + + return true; } /* ---------------- @@ -528,7 +532,7 @@ debugStartup(DestReceiver *self, int operation, TupleDesc typeinfo) * debugtup - print one tuple for an interactive backend * ---------------- */ -void +bool debugtup(TupleTableSlot *slot, DestReceiver *self) { TupleDesc typeinfo = slot->tts_tupleDescriptor; @@ -553,6 +557,8 @@ debugtup(TupleTableSlot *slot, DestReceiver *self) printatt((unsigned) i + 1, typeinfo->attrs[i], value); } printf("\t----\n"); + + return true; } /* ---------------- @@ -564,7 +570,7 @@ debugtup(TupleTableSlot *slot, DestReceiver *self) * This is largely same as printtup_20, except we use binary formatting. * ---------------- */ -static void +static bool printtup_internal_20(TupleTableSlot *slot, DestReceiver *self) { TupleDesc typeinfo = slot->tts_tupleDescriptor; @@ -636,4 +642,6 @@ printtup_internal_20(TupleTableSlot *slot, DestReceiver *self) /* Return to caller's context, and flush row's temporary memory */ MemoryContextSwitchTo(oldcontext); MemoryContextReset(myState->tmpcontext); + + return true; } |