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
INSERT 0 6
id | season_start | season_end | event_date |
---|---|---|---|
1 | 2022-01-01 | 2022-01-31 | 2022-01-01 |
2 | 2022-01-01 | 2022-01-31 | 2022-01-02 |
3 | 2022-01-01 | 2022-01-31 | 2022-01-10 |
4 | 2022-01-01 | 2022-01-31 | 2022-01-16 |
5 | 2022-01-01 | 2022-01-31 | 2022-01-18 |
6 | 2022-01-01 | 2022-01-31 | 2022-01-20 |
SELECT 6
id | season_start | season_end | event_date | range_start | range_end |
---|---|---|---|---|---|
1 | 2022-01-01 | 2022-01-31 | 2022-01-01 | 2022-01-01 | 2022-01-07 |
2 | 2022-01-01 | 2022-01-31 | 2022-01-02 | 2022-01-01 | 2022-01-07 |
3 | 2022-01-01 | 2022-01-31 | 2022-01-10 | 2022-01-08 | 2022-01-16 |
4 | 2022-01-01 | 2022-01-31 | 2022-01-16 | 2022-01-08 | 2022-01-16 |
5 | 2022-01-01 | 2022-01-31 | 2022-01-18 | 2022-01-17 | 2022-01-24 |
6 | 2022-01-01 | 2022-01-31 | 2022-01-20 | 2022-01-17 | 2022-01-24 |
SELECT 6
DELETE 1
id | season_start | season_end | event_date |
---|---|---|---|
1 | 2022-01-01 | 2022-01-31 | 2022-01-01 |
2 | 2022-01-01 | 2022-01-31 | 2022-01-02 |
4 | 2022-01-01 | 2022-01-31 | 2022-01-16 |
5 | 2022-01-01 | 2022-01-31 | 2022-01-18 |
6 | 2022-01-01 | 2022-01-31 | 2022-01-20 |
SELECT 5
id | season_start | season_end | event_date | range_start | range_end |
---|---|---|---|---|---|
1 | 2022-01-01 | 2022-01-31 | 2022-01-01 | 2022-01-01 | 2022-01-07 |
2 | 2022-01-01 | 2022-01-31 | 2022-01-02 | 2022-01-01 | 2022-01-07 |
4 | 2022-01-01 | 2022-01-31 | 2022-01-16 | 2022-01-08 | 2022-01-22 |
5 | 2022-01-01 | 2022-01-31 | 2022-01-18 | 2022-01-08 | 2022-01-22 |
6 | 2022-01-01 | 2022-01-31 | 2022-01-20 | 2022-01-08 | 2022-01-22 |
SELECT 5