Re: Additional improvements to extended statistics
Dean Rasheed <dean.a.rasheed@gmail.com>
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2020-03-09T08:35:48Z
Lists: pgsql-hackers
On Mon, 9 Mar 2020 at 00:02, Tomas Vondra <tomas.vondra@2ndquadrant.com> wrote: > > Speaking of which, would you take a look at [1]? I think supporting SAOP > is fine, but I wonder if you agree with my conclusion we can't really > support inclusion @> as explained in [2]. > Hmm, I'm not sure. However, thinking about your example in [2] reminds me of a thought I had a while ago, but then forgot about --- there is a flaw in the formula used for computing probabilities with functional dependencies: P(a,b) = P(a) * [f + (1-f)*P(b)] because it might return a value that is larger that P(b), which obviously should not be possible. We should amend that formula to prevent a result larger than P(b). The obvious way to do that would be to use: P(a,b) = Min(P(a) * [f + (1-f)*P(b)], P(b)) but actually I think it would be better and more principled to use: P(a,b) = f*Min(P(a),P(b)) + (1-f)*P(a)*P(b) I.e., for those rows believed to be functionally dependent, we use the minimum probability, and for the rows believed to be independent, we use the product. I think that would solve the problem with the example you gave at the end of [2], but I'm not sure if it helps with the general case. Regards, Dean > [1] https://www.postgresql.org/message-id/flat/13902317.Eha0YfKkKy@pierred-pdoc > [2] https://www.postgresql.org/message-id/20200202184134.swoqkqlqorqolrqv%40development
Commits
-
Improve estimation of ANDs under ORs using extended statistics.
- 4f5760d4afa9 14.0 landed
-
Improve estimation of OR clauses using multiple extended statistics.
- 88b0898fe35a 14.0 landed
-
Improve estimation of OR clauses using extended statistics.
- 25a9e54d2db3 14.0 landed
-
Prevent functional dependency estimates from exceeding column estimates.
- 87779aa47463 13.0 landed
-
Fix wording of several extended stats comments
- 6f72dbc48bf8 13.0 landed
-
Improve test coverage for multi-column MCV lists
- d8cfa82d51f8 13.0 landed
-
Improve test coverage for functional dependencies
- f9696782c701 13.0 landed