pgsql: Restore foreign-key-aware estimation of join relation sizes. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Restore foreign-key-aware estimation of join relation sizes.
Date
Msg-id E1bELpL-0006Km-3u@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Restore foreign-key-aware estimation of join relation sizes.

This patch provides a new implementation of the logic added by commit
137805f89 and later removed by 77ba61080.  It differs from the original
primarily in expending much less effort per joinrel in large queries,
which it accomplishes by doing most of the matching work once per query not
once per joinrel.  Hopefully, it's also less buggy and better commented.
The never-documented enable_fkey_estimates GUC remains gone.

There remains work to be done to make the selectivity estimates account
for nulls in FK referencing columns; but that was true of the original
patch as well.  We may be able to address this point later in beta.
In the meantime, any error should be in the direction of overestimating
rather than underestimating joinrel sizes, which seems like the direction
we want to err in.

Tomas Vondra and Tom Lane

Discussion: <31041.1465069446@sss.pgh.pa.us>

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/100340e2dcd05d6505082a8fe343fb2ef2fa5b2a

Modified Files
--------------
src/backend/nodes/copyfuncs.c             |  26 +++
src/backend/nodes/outfuncs.c              |  60 +++++++
src/backend/optimizer/path/costsize.c     | 275 ++++++++++++++++++++++++++++--
src/backend/optimizer/path/equivclass.c   |  79 +++++++++
src/backend/optimizer/plan/analyzejoins.c |   5 +
src/backend/optimizer/plan/initsplan.c    | 153 +++++++++++++++++
src/backend/optimizer/plan/planmain.c     |   9 +
src/backend/optimizer/util/plancat.c      |  98 +++++++++++
src/backend/optimizer/util/relnode.c      |   4 +-
src/backend/utils/cache/relcache.c        | 153 ++++++++++++++++-
src/include/nodes/nodes.h                 |   4 +-
src/include/nodes/relation.h              |  32 ++++
src/include/optimizer/cost.h              |   4 +-
src/include/optimizer/paths.h             |   3 +
src/include/optimizer/planmain.h          |   1 +
src/include/utils/rel.h                   |  32 ++++
src/include/utils/relcache.h              |   1 +
17 files changed, 921 insertions(+), 18 deletions(-)


pgsql-committers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: pgsql: Try again to fix the way the scanjoin_target is used with partia
Next
From: Tom Lane
Date:
Subject: pgsql: Update 9.6 release notes through today.