postgresql/src/include/optimizer
Tom Lane 4387cf956b Avoid inserting Result nodes that only compute identity projections.
The planner sometimes inserts Result nodes to perform column projections
(ie, arbitrary scalar calculations) above plan nodes that lack projection
logic of their own.  However, we did that even if the lower plan node was
in fact producing the required column set already; which is a pretty common
case given the popularity of "SELECT * FROM ...".  Measurements show that
the useless plan node adds non-negligible overhead, especially when there
are many columns in the result.  So add a check to avoid inserting a Result
node unless there's something useful for it to do.

There are a couple of remaining places where unnecessary Result nodes
could get inserted, but they are (a) much less performance-critical,
and (b) coded in such a way that it's hard to avoid inserting a Result,
because the desired tlist is changed on-the-fly in subsequent logic.
We'll leave those alone for now.

Kyotaro Horiguchi; reviewed and further hacked on by Amit Kapila and
Tom Lane.
2013-03-14 13:43:18 -04:00
..
clauses.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
cost.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
geqo.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
geqo_copy.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
geqo_gene.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
geqo_misc.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
geqo_mutation.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
geqo_pool.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
geqo_random.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
geqo_recombination.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
geqo_selection.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
joininfo.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
pathnode.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
paths.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
placeholder.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
plancat.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
planmain.h Support writable foreign tables. 2013-03-10 14:16:02 -04:00
planner.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
predtest.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
prep.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
restrictinfo.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
subselect.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
tlist.h Avoid inserting Result nodes that only compute identity projections. 2013-03-14 13:43:18 -04:00
var.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00