Hi Rick, I am working with data with a similar structure. The most recent data is accessed significantly more often than older data, so my next step will be to have very recent data in hourly tables, then daily, and probably monthly tables for what is effectively archived data. My data is a little different in that it’s stored by the start of an “interval” which means I can do a = comparison for the start of the hour (or day once data is aggregated). I found a similar interesting partitioning performance issue recently when partitioning by timestamp, where if your where clause for a timestamp includes math the planner runs very slowly. In my case saying something like: ``` select * from table where ts = some_time_variable - interval ‘1 hour’; ``` is *much* slower than something like: ``` offset_time_variable = some_time_variable - '1 hour’ interval; select * from table where ts = offset_time_variable; ``` Everything is `timestamp with time zone`. I believe that it’s calculating that offset for each partition - of which there are a couple hundred - and it was causing the planner to run very slowly. Pruning works correctly once the planner has run. This is on postgres 13 - I have yet to try 14 and see if this issue persists in 14. Changing my main query to the above structure significantly improved performance - I was previously having lots of performance issues when aggregation tasks ran and dropped partitions etc. I posted about this here: https://www.postgresql.org/message-id/84101021-8B67-45AD-83F2-A3C8F0AA4BEE%40daork.net -- Nathan Ward |