aboutsummaryrefslogtreecommitdiff
path: root/src/include/executor/execdesc.h
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2017-03-23 13:05:48 -0400
committerRobert Haas <rhaas@postgresql.org>2017-03-23 13:14:36 -0400
commit691b8d59281b5177f16fe80858df921f77a8e955 (patch)
tree8708ae434bf120e73f93e3ef43779d761438ba79 /src/include/executor/execdesc.h
parent218f51584d5a9fcdf702bcc7f54b5b65e255c187 (diff)
downloadpostgresql-691b8d59281b5177f16fe80858df921f77a8e955.tar.gz
postgresql-691b8d59281b5177f16fe80858df921f77a8e955.zip
Allow for parallel execution whenever ExecutorRun() is done only once.
Previously, it was unsafe to execute a plan in parallel if ExecutorRun() might be called with a non-zero row count. However, it's quite easy to fix things up so that we can support that case, provided that it is known that we will never call ExecutorRun() a second time for the same QueryDesc. Add infrastructure to signal this, and cross-checks to make sure that a caller who claims this is true doesn't later reneg. While that pattern never happens with queries received directly from a client -- there's no way to know whether multiple Execute messages will be sent unless the first one requests all the rows -- it's pretty common for queries originating from procedural languages, which often limit the result to a single tuple or to a user-specified number of tuples. This commit doesn't actually enable parallelism in any additional cases, because currently none of the places that would be able to benefit from this infrastructure pass CURSOR_OPT_PARALLEL_OK in the first place, but it makes it much more palatable to pass CURSOR_OPT_PARALLEL_OK in places where we currently don't, because it eliminates some cases where we'd end up having to run the parallel plan serially. Patch by me, based on some ideas from Rafia Sabih and corrected by Rafia Sabih based on feedback from Dilip Kumar and myself. Discussion: http://postgr.es/m/CA+TgmobXEhvHbJtWDuPZM9bVSLiTj-kShxQJ2uM5GPDze9fRYA@mail.gmail.com
Diffstat (limited to 'src/include/executor/execdesc.h')
-rw-r--r--src/include/executor/execdesc.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/include/executor/execdesc.h b/src/include/executor/execdesc.h
index c99ea818158..87e7ca85082 100644
--- a/src/include/executor/execdesc.h
+++ b/src/include/executor/execdesc.h
@@ -47,6 +47,9 @@ typedef struct QueryDesc
EState *estate; /* executor's query-wide state */
PlanState *planstate; /* tree of per-plan-node state */
+ /* This field is set by ExecutorRun */
+ bool already_executed; /* true if previously executed */
+
/* This is always set NULL by the core system, but plugins can change it */
struct Instrumentation *totaltime; /* total time spent in ExecutorRun */
} QueryDesc;