forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit87779aa
committed
Prevent functional dependency estimates from exceeding column estimates.
Formerly we applied a functional dependency "a => b with dependencydegree f" using the formula P(a,b) = P(a) * [f + (1-f)*P(b)]This leads to the possibility that the combined selectivity P(a,b)could exceed P(b), which is not ideal. The addition of support for INand OR clauses (commits8f321bd andccaa356) would seem to makethis more likely, since the user-supplied values in such clauses arenot necessarily compatible with the functional dependency.Mitigate this by using the formula P(a,b) = f * Min(P(a), P(b)) + (1-f) * P(a) * P(b)instead, which guarantees that the combined selectivity is less thaneach column's individual selectivity. Logically, this is modifies thepart of the formula that accounts for dependent rows to handle caseswhere P(a) > P(b), whilst not changing the second term which accountsfor independent rows.Additionally, this refactors the way that functional dependencies areapplied, so now dependencies_clauselist_selectivity() estimates boththe implying clauses and the implied clauses for each functionaldependency (formerly only the implied clauses were estimated), and nowall clauses for each attribute are taken into account (formerly onlyone clause for each implied attribute was estimated). This removes thepreviously built-in assumption that only equality clauses will beseen, which is no longer true, and opens up the possibility ofapplying functional dependencies to more general clauses.Patch by me, reviewed by Tomas Vondra.Discussion:https://postgr.es/m/CAEZATCXaNFZyOhR4XXAfkvj1tibRBEjje6ZbXwqWUB_tqbH%3Drw%40mail.gmail.comDiscussion:https://postgr.es/m/20200318002946.6dvblukm3cfmgir2%40development1 parent145cb16 commit87779aa
File tree
3 files changed
+266
-109
lines changed- src
- backend/statistics
- test/regress
- expected
- sql
3 files changed
+266
-109
lines changed0 commit comments
Comments
(0)