From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Anj Adu <fotographs(at)gmail(dot)com> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: partition pruning |
Date: | 2010-03-04 22:40:02 |
Message-ID: | 603c8f071003041440r2ec69a9dw91153f35ab2b3d53@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On Mon, Mar 1, 2010 at 2:29 PM, Anj Adu <fotographs(at)gmail(dot)com> wrote:
> When I use intervals in my query e.g col1 between current_timestamp -
> interval '10 days' and current_timestamp...the optimizer checks ALL
> partitions whereas if I use col1 between 2 hardcoded dates..only
> the applicable partitions are scanned.
Yep. This is one example of a more general principle:
constant-folding happens before planning, but anything more complex
has to wait until execution time. So the plan can't take into account
the value of current_timestamp in forming the plan.
Unfortunately I don't think there's really any easy way around this:
you have to do select current_timestamp, current_timestamp - interval
'10 days' first and then build & execute a new query.
...Robert
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Berkus | 2010-03-07 17:57:26 | Re: Estimation issue with partitioned tables |
Previous Message | Robert Haas | 2010-03-04 02:07:11 | Re: Estimation issue with partitioned tables |