Re: [HACKERS] PATCH: multivariate histograms and MCV lists
От | Dean Rasheed |
---|---|
Тема | Re: [HACKERS] PATCH: multivariate histograms and MCV lists |
Дата | |
Msg-id | CAEZATCUk5rfLxm60W0VYT8zF2trFRRBonJKTwF46s+hjr28Fyw@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: [HACKERS] PATCH: multivariate histograms and MCV lists (Tomas Vondra <tomas.vondra@2ndquadrant.com>) |
Ответы |
Re: [HACKERS] PATCH: multivariate histograms and MCV lists
|
Список | pgsql-hackers |
On 27 March 2018 at 01:36, Tomas Vondra <tomas.vondra@2ndquadrant.com> wrote: > 4) handling of NOT clauses in MCV lists (and in histograms) > > The query you posted does not fail anymore... > Ah, it turns out the previous query wasn't actually failing for the reason I thought it was -- it was failing because it had a ScalarArrayOpExpr that was being passed to mcv_clauselist_selectivity() because of the wrong list being passed to it. I could see from the code that a NOT clause would have tripped it up, but most NOT clauses actually get rewritten by negate_clause() so they end up not being NOT clauses. One way to get a NOT clause, is with a boolean column, and this reveals another couple of problems: drop table if exists foo; create table foo(a int, b boolean); insert into foo values(1,true); insert into foo values(1,true); insert into foo values(1,false); create statistics foo_mcv_ab (mcv) on a,b from foo; analyse foo; select * from foo where a=1 and b; ERROR: unknown clause type: 99 This fails because the clause is now a Var, which statext_is_compatible_clause() lets through, but mcv_clauselist_selectivity() doesn't support. So it's important to keep those 2 functions in sync, and it might be worth having comments in each to emphasise that. And, if a NOT clause is used: select * from foo where a=1 and not b; server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. The connection to the server was lost. Attempting reset: Failed. This is an Assert failure in mcv_update_match_bitmap()'s BoolExpr handling block: Assert(bool_clauses != NIL); Assert(list_length(bool_clauses) >= 2); The first of those Asserts is actually redundant with the second, but the second fails because a NOT clause always only has one argument. Regards, Dean
В списке pgsql-hackers по дате отправления: