pgsql: Avoid inserting Result nodes that only compute identity projecti

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Avoid inserting Result nodes that only compute identity projecti
Дата
Msg-id E1UGCBh-0006P3-A0@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
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.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/4387cf956b9eb13aad569634e0c4df081d76e2e3

Modified Files
--------------
src/backend/optimizer/plan/createplan.c   |    8 ++-
src/backend/optimizer/plan/planner.c      |   17 +++--
src/backend/optimizer/util/tlist.c        |   37 ++++++++++
src/include/optimizer/tlist.h             |    3 +
src/test/regress/expected/alter_table.out |   88 +++++++++++------------
src/test/regress/expected/inherit.out     |  110 ++++++++++++++---------------
src/test/regress/expected/union.out       |   28 ++++----
7 files changed, 163 insertions(+), 128 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: pgsql: Change the way UESCAPE is lexed, to reduce the size of the flex
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Minor fixes for hstore_to_json_loose().