pgsql: Fix planning of parameterized appendrel paths with expensive joi

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix planning of parameterized appendrel paths with expensive joi
Date: 2013-07-08 02:37:55
Message-ID: E1Uw1Kt-0004vv-TZ@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix planning of parameterized appendrel paths with expensive join quals.

The code in set_append_rel_pathlist() for building parameterized paths
for append relations (inheritance and UNION ALL combinations) supposed
that the cheapest regular path for a child relation would still be cheapest
when reparameterized. Which might not be the case, particularly if the
added join conditions are expensive to compute, as in a recent example from
Jeff Janes. Fix it to compare child path costs *after* reparameterizing.
We can short-circuit that if the cheapest pre-existing path is already
parameterized correctly, which seems likely to be true often enough to be
worth checking for.

Back-patch to 9.2 where parameterized paths were introduced.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/5372275b4b5fc183c6c6dd4517cfd74d5b641446

Modified Files
--------------
src/backend/optimizer/path/allpaths.c | 104 +++++++++++++++++++++++++++------
src/test/regress/expected/union.out | 34 +++++++++++
src/test/regress/sql/union.sql | 21 +++++++
3 files changed, 140 insertions(+), 19 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2013-07-08 09:16:32 pgsql: Improve scalability of WAL insertions.
Previous Message Claudio Freire 2013-07-07 22:16:52 Re: [COMMITTERS] pgsql: PL/Python: Convert numeric to Decimal