Re: [HACKERS] path toward faster partition pruning

From: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
To: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
Cc: Rajkumar Raghuwanshi <rajkumar(dot)raghuwanshi(at)enterprisedb(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>, Jesper Pedersen <jesper(dot)pedersen(at)redhat(dot)com>, Amit Langote <amitlangote09(at)gmail(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Beena Emerson <memissemerson(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] path toward faster partition pruning
Date: 2018-02-22 09:48:51
Message-ID: fd1feaeb-f6fb-b63e-65aa-d610f76759a9@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2018/02/22 17:41, David Rowley wrote:
> On 21 February 2018 at 23:44, Amit Langote
> <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2018-02-22 11:28:13 Re: [HACKERS] path toward faster partition pruning
Previous Message Amit Langote 2018-02-22 09:31:23 Re: [HACKERS] Runtime Partition Pruning