diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2016-06-18 15:22:34 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2016-06-18 15:22:34 -0400 |
commit | 100340e2dcd05d6505082a8fe343fb2ef2fa5b2a (patch) | |
tree | eb41564ad79ab0ab0557471ea004f58a9b26a753 /src/backend/optimizer/plan/planmain.c | |
parent | 598aa194af2fb7f294ae4b029494a134a44be333 (diff) |
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>
Diffstat (limited to 'src/backend/optimizer/plan/planmain.c')
-rw-r--r-- | src/backend/optimizer/plan/planmain.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/backend/optimizer/plan/planmain.c b/src/backend/optimizer/plan/planmain.c index edd95d8de13..27234ffa224 100644 --- a/src/backend/optimizer/plan/planmain.c +++ b/src/backend/optimizer/plan/planmain.c @@ -115,6 +115,7 @@ query_planner(PlannerInfo *root, List *tlist, root->full_join_clauses = NIL; root->join_info_list = NIL; root->placeholder_list = NIL; + root->fkey_list = NIL; root->initial_rels = NIL; /* @@ -206,6 +207,14 @@ query_planner(PlannerInfo *root, List *tlist, create_lateral_join_info(root); /* + * Match foreign keys to equivalence classes and join quals. This must be + * done after finalizing equivalence classes, and it's useful to wait till + * after join removal so that we can skip processing foreign keys + * involving removed relations. + */ + match_foreign_keys_to_quals(root); + + /* * Look for join OR clauses that we can extract single-relation * restriction OR clauses from. */ |