pgsql: Don't make FK-based selectivity estimates in inheritance situati

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Don't make FK-based selectivity estimates in inheritance situati
Date: 2016-11-02 19:50:41
Message-ID: E1c21YX-0006Fk-H6@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Don't make FK-based selectivity estimates in inheritance situations.

The foreign-key-aware logic for estimation of join sizes (added in commit
100340e2d) blindly tried to apply the concept to rels that are actually
parents of inheritance trees. This is just plain wrong so far as the
referenced relation is concerned, since the inheritance scan may well
produce lots of rows that are not participating in the constraint. It's
wrong for the referencing relation too, for the same reason; although on
that end we could conceivably detect whether all members of the inheritance
tree have equivalent FK constraints pointing to the same referenced rel,
and then proceed more or less as we do now. But pending somebody writing
code to do that, we must disable this, because it's producing completely
silly estimates when there's an FK linking the heads of inheritance trees.

Per bug #14404 from Clinton Adams. Back-patch to 9.6 where the new
estimation logic came in.

Report: <20161028200412(dot)15987(dot)96482(at)wrigleys(dot)postgresql(dot)org>

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/770671062f130a830aa89100c9aa2d26f8d4bf32

Modified Files
--------------
src/backend/optimizer/util/plancat.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2016-11-03 13:46:29 pgsql: libpq: Allow connection strings and URIs to specify multiple hos
Previous Message Tom Lane 2016-11-02 18:32:23 pgsql: Don't convert Consts into Vars during setrefs.c processing.