-
My table contains 2 timestamp columns start_time and end_time.
My clients will be sending filters that contain any combination of these two columns. I want to range partition this table in daily intervals. How do I make sure constraint exclusion (partition pruning) works correctly with filters against either or both the /cc @keithf4 I believe it would work If I partitioned by start_time AND changed your apply_constraints script to create a check for the end_time that was not based on min/max of existing data but was simply based on the existing start_time ranges of each partition. I would like to copy over the start_time boundaries of each partition to the end_time CHECK for that same partition. Makes sense? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
The extra constraints that apply_constraints provides would be the way to do this since pg_partman currently only supports single column partitioning. That should work for you, but I probably won't be able to adapt that code back into pg_partman at this time since this is very specific to your use-case. But honestly, this may be a better candidate for using the ranged data type (tstzrange) depending on your usage. https://www.postgresql.org/docs/13/rangetypes.html This data type isn't currently supported in partitioning as far as I'm aware, but it can make writing queries for time ranges like this significantly easier and provides many more flexible operations (overlap, intersect, right of, left of, etc). |
Beta Was this translation helpful? Give feedback.
The extra constraints that apply_constraints provides would be the way to do this since pg_partman currently only supports single column partitioning. That should work for you, but I probably won't be able to adapt that code back into pg_partman at this time since this is very specific to your use-case.
But honestly, this may be a better candidate for using the ranged data type (tstzrange) depending on your usage.
https://www.postgresql.org/docs/13/rangetypes.html
https://www.postgresql.org/docs/13/functions-range.html
This data type isn't currently supported in partitioning as far as I'm aware, but it can make writing queries for time ranges like this significantly easier and provides ma…