]> granicus.if.org Git - postgresql/commit
Restore foreign-key-aware estimation of join relation sizes.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 18 Jun 2016 19:22:34 +0000 (15:22 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 18 Jun 2016 19:22:34 +0000 (15:22 -0400)
commit100340e2dcd05d6505082a8fe343fb2ef2fa5b2a
treeeb41564ad79ab0ab0557471ea004f58a9b26a753
parent598aa194af2fb7f294ae4b029494a134a44be333
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>
17 files changed:
src/backend/nodes/copyfuncs.c
src/backend/nodes/outfuncs.c
src/backend/optimizer/path/costsize.c
src/backend/optimizer/path/equivclass.c
src/backend/optimizer/plan/analyzejoins.c
src/backend/optimizer/plan/initsplan.c
src/backend/optimizer/plan/planmain.c
src/backend/optimizer/util/plancat.c
src/backend/optimizer/util/relnode.c
src/backend/utils/cache/relcache.c
src/include/nodes/nodes.h
src/include/nodes/relation.h
src/include/optimizer/cost.h
src/include/optimizer/paths.h
src/include/optimizer/planmain.h
src/include/utils/rel.h
src/include/utils/relcache.h