On 12/16/2014 05:52 PM, Robert Haas wrote:
> But in a more complicated case where the value there isn't known until
> runtime, yeah, it scans everything. I'm not sure what the best way to
> fix that is. If the partition bounds were stored in a structured way,
> as we've been discussing, then the Append or Merge Append node could,
> when initialized, check which partition the id = X qual routes to and
> ignore the rest. But that's more iffy with the current
> representation, I think.
Huh. I was just testing:
WHERE event_time BETWEEN timestamptz '2014-12-01' and ( timestamptz
'2014-12-01' + interval '1 month')
In that case, the expression above got folded to constants by the time
Postgres did the index scans, but it scanned all partitions. So somehow
(timestamptz + interval) doesn't get constant-folded until after
planning, at least not on 9.3.
And of course this leaves out common patterns like "now() - interval '30
days'" or "to_timestamp('20141201','YYYYMMDD')"
Anyway, what I'm saying is that I personally regard the inability to
handle even moderately complex expressions a major failing of our
existing partitioning scheme (possibly its worst single failing), and I
would regard any new partitioning feature which didn't address that
issue as suspect.
--
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com