Re: BUG #18344: Pruning tables partitioned by bool range fails with invalid strategy
От | David Rowley |
---|---|
Тема | Re: BUG #18344: Pruning tables partitioned by bool range fails with invalid strategy |
Дата | |
Msg-id | CAApHDvoFbt0fne1C_prK5j0MvxHccJD7NxUY0UDaTtAZuEyxrg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: BUG #18344: Pruning tables partitioned by bool range fails with invalid strategy (David Rowley <dgrowleyml@gmail.com>) |
Ответы |
Re: BUG #18344: Pruning tables partitioned by bool range fails with invalid strategy
|
Список | pgsql-bugs |
On Sat, 17 Feb 2024 at 01:32, David Rowley <dgrowleyml@gmail.com> wrote: > I see three options: > > 1) Make get_matching_list_bounds() work for bool IS NOT clauses by > properly including the NULL partition when handling a bool IS NOT > clause. > 2) Just don't generate a pruning step for bool IS NOT clauses. > 3) Just always include the NULL partition in > get_matching_list_bounds's "if (opstrategy == InvalidStrategy)" block. It turns out there's a 4th, and much better option that allows this just to work without any weirdness. The method used in partprune.c to handle "partkey IN ('const1', 'const2')" is to transform that into "partkey = 'const1' OR partkey = 'const2'". Whenever we see a ScalarArrayOpExpr with consts, we just form such an OR clause and recursively generate pruning steps for the OR clause. That'll end up creating two pruning steps and combining them with a PARTPRUNE_COMBINE_UNION. We can do the same for BooleanTests. Given a clause such as: "partkey IS NOT false", we can just generate the clause "partkey IS true OR partkey IS NULL" and recursively generate steps for that. I've attached a draft patch. I'll work on this more after I sleep. I'm tempted to go a bit further in master only and add support for bool IS NOT UNKNOWN and bool IS UNKNOWN using the same method. David
Вложения
В списке pgsql-bugs по дате отправления: