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?.
DROP TABLE
CREATE TABLE
INSERT 0 23
ts | name |
---|---|
2024-07-01 14:05:00+01 | Bob |
2024-07-01 13:48:00+01 | Bob |
2024-07-01 13:44:00+01 | Bob |
2024-07-01 13:35:00+01 | Bob |
2024-07-01 13:30:00+01 | Alice |
2024-07-01 13:26:00+01 | Alice |
2024-07-01 13:25:00+01 | Bob |
2024-07-01 13:21:00+01 | Alice |
2024-07-01 13:20:00+01 | Bob |
2024-07-01 13:17:00+01 | Alice |
2024-07-01 13:14:00+01 | Bob |
2024-07-01 13:14:00+01 | Alice |
2024-07-01 13:12:00+01 | Alice |
2024-07-01 13:09:00+01 | Bob |
2024-07-01 13:05:00+01 | Alice |
2024-07-01 13:05:00+01 | Bob |
2024-07-01 13:04:00+01 | Alice |
2024-07-01 13:03:00+01 | Alice |
2024-07-01 13:02:00+01 | Bob |
2024-07-01 13:02:00+01 | Alice |
2024-07-01 13:01:00+01 | Alice |
2024-07-01 13:00:00+01 | Bob |
2024-07-01 13:00:00+01 | Alice |
SELECT 23
session_seq | unique_id | name | event_count | start_ts | end_ts | session_duration |
---|---|---|---|---|---|---|
1 | Alice-1 | Alice | 6 | 2024-07-01 13:00:00+01 | 2024-07-01 13:05:00+01 | 00:05:00 |
2 | Alice-2 | Alice | 6 | 2024-07-01 13:12:00+01 | 2024-07-01 13:30:00+01 | 00:18:00 |
1 | Bob-1 | Bob | 5 | 2024-07-01 13:00:00+01 | 2024-07-01 13:14:00+01 | 00:14:00 |
2 | Bob-2 | Bob | 2 | 2024-07-01 13:20:00+01 | 2024-07-01 13:25:00+01 | 00:05:00 |
3 | Bob-3 | Bob | 1 | 2024-07-01 13:35:00+01 | 2024-07-01 13:35:00+01 | 00:01:00 |
4 | Bob-4 | Bob | 2 | 2024-07-01 13:44:00+01 | 2024-07-01 13:48:00+01 | 00:04:00 |
5 | Bob-5 | Bob | 1 | 2024-07-01 14:05:00+01 | 2024-07-01 14:05:00+01 | 00:01:00 |
SELECT 7