pgsql: Drop cheap-startup-cost paths during add_path() if we don't need

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Drop cheap-startup-cost paths during add_path() if we don't need
Date: 2012-09-01 22:16:38
Message-ID: E1T7vza-0001EV-K7@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Drop cheap-startup-cost paths during add_path() if we don't need them.

We can detect whether the planner top level is going to care at all about
cheap startup cost (it will only do so if query_planner's tuple_fraction
argument is greater than zero). If it isn't, we might as well discard
paths immediately whose only advantage over others is cheap startup cost.
This turns out to get rid of quite a lot of paths in complex queries ---
I saw planner runtime reduction of more than a third on one large query.

Since add_path isn't currently passed the PlannerInfo "root", the easiest
way to tell it whether to do this was to add a bool flag to RelOptInfo.
That's a bit redundant, since all relations in a given query level will
have the same setting. But in the future it's possible that we'd refine
the control decision to work on a per-relation basis, so this seems like
a good arrangement anyway.

Per my suggestion of a few months ago.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/6d2c8c0e2afa8cbaf99555a24336e93118fd181e

Modified Files
--------------
src/backend/nodes/outfuncs.c | 1 +
src/backend/optimizer/util/pathnode.c | 25 +++++++++++++++++++------
src/backend/optimizer/util/relnode.c | 4 ++++
src/include/nodes/relation.h | 5 +++++
src/test/regress/expected/join.out | 11 ++++++-----
src/test/regress/sql/join.sql | 1 +
6 files changed, 36 insertions(+), 11 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2012-09-02 12:42:06 pgsql: Add small doc mention that libpq is named after POSTQUEL.
Previous Message Tom Lane 2012-09-01 17:57:02 pgsql: Fix mark_placeholder_maybe_needed to handle LATERAL references.