Hi, i found something wrong with new partition mechanism in postgresql 10.1 I have table partitioned by time stored as epoch time. Each partition is one month (my time is GMT+1). I tried to make script, that's count rows from last month. I wrote something like this:
SELECT count(*) FROM trends where clock between (extract(epoch from (date_trunc ('month', CURRENT_DATE)- interval '1 month')::date)::integer - 3600 ) and (extract(epoch from date_trunc ('month', CURRENT_DATE)::date)::integer - 3601 )
Problem is, that all partitions are scanned.
Partition pruning has to happen at planning time, but the time when the query is executed can differ from the time it was planned, so pruning can't be done based on expressions like CURRENT_DATE. This might be improved in the future.