Suppose I have a table partitioned by month in postgres where the following are true:
- Records are never updated.
- New records are only added with the current time, give or take a few minutes.
- A trigger handles inserts so records only go into this month’s partition or last month’s.
Do constraint checks on the partitions / child tables help me here? Since the trigger handles the end-of-month period, it seems they would be redundant and thus unhelpful, but I feel I might be missing something.
The constraints are needed for the query planner, it uses the constraint to know where to find specific data. See the documentation.