By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Help with an interesting Postgres question: Why isn't an Index Only Scan used on a partition accessed via the parent table?.
CREATE TABLE
consumer_id | start_time | end_time |
---|---|---|
1 | 2023-09-24 20:00:00 | 2023-09-25 00:00:00 |
2 | 2023-09-24 21:00:00 | 2023-09-25 13:00:00 |
1 | 2023-09-26 20:00:00 | 2023-09-28 02:00:00 |
3 | 2023-09-25 19:00:00 | 2023-09-26 10:00:00 |
5 | 2023-09-25 21:30:00 | 2023-09-25 22:00:00 |
INSERT 0 5
CREATE TABLE
INSERT 0 9
consumer_id | start_time | end_time | isdaydiff |
---|---|---|---|
1 | 2023-09-24 20:00:00 | 2023-09-25 00:00:00 | 0 |
1 | 2023-09-26 20:00:00 | 2023-09-27 00:00:00 | 1 |
1 | 2023-09-27 00:00:00 | 2023-09-28 00:00:00 | 1 |
1 | 2023-09-28 00:00:00 | 2023-09-28 02:00:00 | 1 |
2 | 2023-09-24 21:00:00 | 2023-09-25 00:00:00 | 1 |
2 | 2023-09-25 00:00:00 | 2023-09-25 13:00:00 | 1 |
3 | 2023-09-25 19:00:00 | 2023-09-26 00:00:00 | 1 |
3 | 2023-09-26 00:00:00 | 2023-09-26 10:00:00 | 1 |
5 | 2023-09-25 21:30:00 | 2023-09-25 22:00:00 | 0 |
SELECT 9