Postgresql: Partition table by hour
For partition pruning to work, it is important that your partition key is simple and part of the where clause of your queries. In your example you can simplify to
check((extract(hour from &quot;timestamp&quot;)) = 0  # equality
check((extract(hour from &quot;timestamp&quot;)) = 1  # etc.
check((extract(hour from &quot;timestamp&quot;)) = 23

At this time it would be a nice use case for timescaleDB which does a lot of this all automatically for you.