Re: Planning of sub partitions

2024-07-05 Thread David Rowley
On Sat, 6 Jul 2024 at 03:24, Matt Hughes wrote: > -- 4. uses all partitions; should exclude event_closed_y2024_m02 > explain select * from event > where > cleared is false OR > (cleared is true and date_raised > '2024-01-01' AND date_raised < > '2024-01-02'); >

Re: Planning of sub partitions

2024-07-05 Thread Matt Hughes
One workaround seems to be using a CTE with a union: with openAndRecentlyRaisedEvents as ( select * from event where cleared is false union all select * from event where cleared is true and date_raised > '2024-01-01' AND date_raised < '2024-01-02'; ) select * from openAndREcentlyRaisedEven

Planning of sub partitions

2024-07-05 Thread Matt Hughes
I am trying to model a stateful `event` table using partitions. An event has date_raised (not null) and date_cleared (nullable) columns. An event is in the "open" state when it has a null date_cleared; it is in the "closed" state when date_cleared is set. Once date_cleared is set, it won't chang