Re: [HACKERS] path toward faster partition pruning

Поиск
Список
Период
Сортировка
От Amit Langote
Тема Re: [HACKERS] path toward faster partition pruning
Дата
Msg-id fd1feaeb-f6fb-b63e-65aa-d610f76759a9@lab.ntt.co.jp
обсуждение исходный текст
Ответ на Re: [HACKERS] path toward faster partition pruning  (David Rowley <david.rowley@2ndquadrant.com>)
Ответы Re: [HACKERS] path toward faster partition pruning
Список pgsql-hackers
On 2018/02/22 17:41, David Rowley wrote:
> On 21 February 2018 at 23:44, Amit Langote
> <Langote_Amit_f8@lab.ntt.co.jp> wrote:
>> Please find attached updated patches.
> 
> Thanks for updating the code.
> 
> The question I have now is around NULL handling in
> partkey_datum_from_expr(). I've not managed to find a way to get a
> NULL Const in there as it seems all the clauses I try get removed
> somewhere earlier in planning. Do you know for a fact that a NULL
> Const is impossible to get there?

We only ever call partkey_datum_from_expr() for an OpExpr's arg and if you
have a NULL Const in there, eval_const_expressions() would've folded the
OpExpr's and subsequently any AND'd OpExpr's into a constant-false qual.


create table p (a int) partition by list (a);
create table p1 partition of p for values in (1);
create table p2 partition of p for values in (2);

explain select * from p where a = null and a = 1;
                QUERY PLAN
-------------------------------------------
 Result  (cost=0.00..0.00 rows=0 width=40)
   One-Time Filter: false

explain select * from p where (a = null and a = 1) or a = 2;
                        QUERY PLAN
----------------------------------------------------------
 Append  (cost=0.00..41.94 rows=13 width=4)
   ->  Seq Scan on p2  (cost=0.00..41.88 rows=13 width=4)
         Filter: (a = 2)
(3 rows)

> I'm having to add some NULL handling there for the run-time pruning
> patch but wondered if it was also required for your patch.

Hmm, not sure why.  Can you explain a bit more?

Thanks,
Amit



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Amit Langote
Дата:
Сообщение: Re: [HACKERS] Runtime Partition Pruning
Следующее
От: David Rowley
Дата:
Сообщение: Re: [HACKERS] path toward faster partition pruning