Re: [HACKERS] PATCH: multivariate histograms and MCV lists
Dean Rasheed <dean.a.rasheed@gmail.com>
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: Bruce Momjian <bruce@momjian.us>,
Alvaro Herrera <alvherre@2ndquadrant.com>, Andres Freund <andres@anarazel.de>,
Thomas Munro <thomas.munro@enterprisedb.com>, Mark Dilger <hornschnorter@gmail.com>,
Adrien Nayrat <adrien.nayrat@dalibo.com>, Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2018-07-15T14:43:36Z
Lists: pgsql-hackers
On 15 July 2018 at 14:29, Tomas Vondra <tomas.vondra@2ndquadrant.com> wrote: > It's quite unclear to me how this algorithm could reliably end up with > hist_sel=0 (in cases where we already don't end up with that). I mean, > if a bucket matches the conditions, then the only way to eliminate is by > deducing that MCV already contains all the matches - and that's rather > difficult for complex clauses ... Ah, I didn't realise that you were using histograms for equality clauses as well. I had assumed that they would only use the MCV stats, as in the univariate case. Using histograms for equality seems problematic -- if bucket_contains_value() returns STATS_MATCH_PARTIAL, as things stand that would end up with an estimate of half the bucket's frequency, which seems excessive. Also, if I'm reading it correctly, the code for histograms with not-equals will return STATS_MATCH_PARTIAL for all but one of the buckets, which isn't great either. > I don't know, really. I'll have to try hacking on this a bit I guess. > But there's one obvious question - in what order should we add the > clauses? Does it matter at all, or what is the optimal order? We don't > need to worry about it now, because we simply consider all clauses at > once, but I guess the proposed algorithm is more sensitive to this. I don't know. That's definitely one of the least satisfactory parts of that idea. The alternative seems to be to improve the match tracking in your current algorithm so that it keeps more detailed information about the kinds of matches seen at each level, and combines them appropriately. Maybe that's possible, but I'm struggling to see exactly how. Counting equality clauses seen on each column might be a start. But it would also need to track inequalities, with min/max values or fractions of the non-MCV total, or some such thing. Regards, Dean
Commits
-
Convert pre-existing stats_ext tests to new style
- dbb984128ebf 12.0 landed
-
Add support for multivariate MCV lists
- 7300a699502f 12.0 landed
-
Improve ANALYZE's strategy for finding MCVs.
- b5db1d93d2a6 11.0 cited
-
Clone extended stats in CREATE TABLE (LIKE INCLUDING ALL)
- 5564c1181548 11.0 cited
-
Try again to fix accumulation of parallel worker instrumentation.
- 8526bcb2df76 11.0 cited
-
Adjust psql \d query to avoid use of @> operator.
- 471d55859c11 11.0 cited
-
Message style fixes
- 821fb8cdbf70 11.0 cited
-
Add security checks to selectivity estimation functions
- e2d4ef8de869 10.0 cited