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
date |
---|
2024-01-01 |
2024-01-02 |
2024-01-03 |
2024-01-04 |
2024-01-05 |
2024-01-06 |
INSERT 0 6
CREATE TABLE
business_date | id |
---|---|
2024-01-01 | 1 |
2024-01-02 | 2 |
2024-01-05 | 4 |
2024-01-06 | 5 |
INSERT 0 4
date | business_date | id |
---|---|---|
2024-01-01 | 2024-01-01 | 1 |
2024-01-02 | 2024-01-02 | 2 |
2024-01-03 | 2024-01-02 | 2 |
2024-01-04 | 2024-01-02 | 2 |
2024-01-05 | 2024-01-05 | 4 |
2024-01-06 | 2024-01-06 | 5 |
SELECT 6
business_date | id | next_business_date | date |
---|---|---|---|
2024-01-01 | 1 | 2024-01-02 | 2024-01-01 |
2024-01-02 | 2 | 2024-01-05 | 2024-01-02 |
2024-01-02 | 2 | 2024-01-05 | 2024-01-03 |
2024-01-02 | 2 | 2024-01-05 | 2024-01-04 |
2024-01-05 | 4 | 2024-01-06 | 2024-01-05 |
2024-01-06 | 5 | 9999-12-31 | 2024-01-06 |
SELECT 6