Re: Query ending up with hitting all the partition with sub-query in the projection list

From: Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org, Rushabh Lathia <rushabh(dot)lathia(at)enterprisedb(dot)com>
Subject: Re: Query ending up with hitting all the partition with sub-query in the projection list
Date: 2012-10-26 17:21:51
Message-ID: CAGPqQf2yzk9_d+X5CngPn_OF5XCbHr0Sad94ZmcnDU6Kb28pmQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Oct 26, 2012 at 10:39 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com> writes:
> > *-- Hitting all the partition table*
> > postgres=# explain select a , ( select city_id from measurement where
> *logdate
> > = test.b and logdate = '2006-02-02')* xyz from test;
>
> Hm. What's happening here is that you get an equivalence class
> containing logdate, test.b, and '2006-02-02', where test.b is actually
> a Param supplied from the outer query level. So the equivclass.c
> machinery considers that both test.b and '2006-02-02' are constants,
> and it just picks the first one to construct derived equalities from.
> So what comes out is "test.b = logdate and test.b = '2006-02-02'", and
> neither of those can be used by the constraint-exclusion machinery to
> prove that some partitions of "measurement" can be skipped.
>
> What we need is to teach generate_base_implied_equalities_const() to
> prefer an actual constant to pseudo-constants. Will fix, thanks for the
> example!
>

Thanks for nice explanation.

>
> regards, tom lane
>

--
Rushabh Lathia

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kevin Grittner 2012-10-26 20:06:05 Re: WIP fix proposal for bug #6123
Previous Message Tom Lane 2012-10-26 17:09:12 Re: Query ending up with hitting all the partition with sub-query in the projection list