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

From Tom Lane
Subject Re: Query ending up with hitting all the partition with sub-query in the projection list
Date
Msg-id 24797.1351271352@sss.pgh.pa.us
Whole thread Raw
In response to Query ending up with hitting all the partition with sub-query in the projection list  (Rushabh Lathia <rushabh.lathia@gmail.com>)
Responses Re: Query ending up with hitting all the partition with sub-query in the projection list  (Rushabh Lathia <rushabh.lathia@gmail.com>)
List pgsql-hackers
Rushabh Lathia <rushabh.lathia@gmail.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!
        regards, tom lane



pgsql-hackers by date:

Previous
From: "David E. Wheeler"
Date:
Subject: Re: Extensions Documentation
Next
From: Rushabh Lathia
Date:
Subject: Re: Query ending up with hitting all the partition with sub-query in the projection list