summaryrefslogtreecommitdiff
path: root/src/backend/executor/execScan.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-05-22 22:30:20 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-05-22 22:30:20 +0000
commite2159f384268e01282af60515582943bf595ba7b (patch)
tree89fa7f4dce0cb8ed7a3296e08e30e71c01f7f84f /src/backend/executor/execScan.c
parentc61207b0913b947d17b837a3d532de81a385977d (diff)
downloadpostgresql-e2159f384268e01282af60515582943bf595ba7b.tar.gz
Teach the planner to remove SubqueryScan nodes from the plan if they
aren't doing anything useful (ie, neither selection nor projection). Also, extend to SubqueryScan the hacks already in place to avoid unnecessary ExecProject calls when the result would just be the same tuple the subquery already delivered. This saves some overhead in UNION and other set operations, as well as avoiding overhead for unflatten-able subqueries. Per example from Sokolov Yura.
Diffstat (limited to 'src/backend/executor/execScan.c')
-rw-r--r--src/backend/executor/execScan.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/backend/executor/execScan.c b/src/backend/executor/execScan.c
index 1e80fa7be0..843aa15101 100644
--- a/src/backend/executor/execScan.c
+++ b/src/backend/executor/execScan.c
@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/execScan.c,v 1.35 2005/03/16 21:38:06 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/execScan.c,v 1.36 2005/05/22 22:30:19 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -48,7 +48,6 @@ TupleTableSlot *
ExecScan(ScanState *node,
ExecScanAccessMtd accessMtd) /* function returning a tuple */
{
- EState *estate;
ExprContext *econtext;
List *qual;
ProjectionInfo *projInfo;
@@ -58,12 +57,17 @@ ExecScan(ScanState *node,
/*
* Fetch data from node
*/
- estate = node->ps.state;
- econtext = node->ps.ps_ExprContext;
qual = node->ps.qual;
projInfo = node->ps.ps_ProjInfo;
/*
+ * If we have neither a qual to check nor a projection to do,
+ * just skip all the overhead and return the raw scan tuple.
+ */
+ if (!qual && !projInfo)
+ return (*accessMtd) (node);
+
+ /*
* Check to see if we're still projecting out tuples from a previous
* scan tuple (because there is a function-returning-set in the
* projection expressions). If so, try to project another one.
@@ -83,6 +87,7 @@ ExecScan(ScanState *node,
* storage allocated in the previous tuple cycle. Note this can't
* happen until we're done projecting out tuples from a scan tuple.
*/
+ econtext = node->ps.ps_ExprContext;
ResetExprContext(econtext);
/*