pgsql: Rewrite the code that applies scan/join targets to paths.

From: Robert Haas <rhaas(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Rewrite the code that applies scan/join targets to paths.
Date: 2018-03-29 19:52:40
Message-ID: E1f1dbE-0006oZ-7Q@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Rewrite the code that applies scan/join targets to paths.

If the toplevel scan/join target list is parallel-safe, postpone
generating Gather (or Gather Merge) paths until after the toplevel has
been adjusted to return it. This (correctly) makes queries with
expensive functions in the target list more likely to choose a
parallel plan, since the cost of the plan now reflects the fact that
the evaluation will happen in the workers rather than the leader.
The original complaint about this problem was from Jeff Janes.

If the toplevel scan/join relation is partitioned, recursively apply
the changes to all partitions. This sometimes allows us to get rid of
Result nodes, because Append is not projection-capable but its
children may be. It also cleans up what appears to be incorrect SRF
handling from commit e2f1eb0ee30d144628ab523432320f174a2c8966: the old
code had no knowledge of SRFs for child scan/join rels.

Because we now use create_projection_path() in some cases where we
formerly used apply_projection_to_path(), this changes the ordering
of columns in some queries generated by postgres_fdw. Update
regression outputs accordingly.

Patch by me, reviewed by Amit Kapila and by Ashutosh Bapat. Other
fixes for this problem (substantially different from this version)
were reviewed by Dilip Kumar, Amit Khandekar, and Marina Polyakova.

Discussion: http://postgr.es/m/CAMkU=1ycXNipvhWuweUVpKuyu6SpNjF=yHWu4c4US5JgVGxtZQ@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/11cf92f6e2e13c0a6e3f98be3e629e6bd90b74d5

Modified Files
--------------
contrib/postgres_fdw/expected/postgres_fdw.out | 81 ++-
src/backend/optimizer/plan/planner.c | 282 ++++++---
src/test/regress/expected/partition_join.out | 772 ++++++++++++-------------
3 files changed, 606 insertions(+), 529 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2018-03-29 20:22:53 pgsql: Remove 'target' from GroupPathExtraData.
Previous Message Robert Haas 2018-03-29 19:46:18 pgsql: Postpone generate_gather_paths for topmost scan/join rel.

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2018-03-29 20:02:07 Re: Changing WAL Header to reduce contention during ReserveXLogInsertLocation()
Previous Message legrand legrand 2018-03-29 19:52:38 Poc: pg_stat_statements with planid