1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-14 18:42:34 +03:00

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.
This commit is contained in:
Tom Lane
2005-05-22 22:30:20 +00:00
parent c61207b091
commit e2159f3842
13 changed files with 605 additions and 177 deletions

View File

@ -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,11 +57,16 @@ 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
@ -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);
/*