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 17
user_id | subscription_type | start_date | end_date |
---|---|---|---|
675 | Premium | 2023-01-01 | 2023-02-15 |
675 | Books | 2023-02-15 | 2023-02-28 |
675 | Premium | 2023-02-28 | 2023-04-18 |
675 | Books | 2023-04-18 | 2023-06-18 |
677 | Premium | 2022-01-01 | 2022-01-01 |
677 | Premium | 2023-01-01 | 2023-02-15 |
677 | Books | 2023-02-15 | 2023-02-28 |
677 | Premium | 2023-02-28 | 2023-04-18 |
677 | Books | 2023-04-18 | 2023-06-18 |
677 | Premium | 2023-06-18 | 2023-07-10 |
699 | Premium | 2023-01-01 | 2023-02-15 |
699 | Books | 2023-02-15 | 2023-02-28 |
699 | Premium | 2023-02-28 | 2023-04-18 |
699 | Books | 2023-04-18 | 2023-06-18 |
699 | Premium | 2023-06-18 | 2023-06-20 |
699 | Books | 2023-06-20 | 2023-06-22 |
699 | Premium | 2023-06-22 | 2023-07-10 |
726 | Premium | 2023-01-01 | 2023-03-16 |
726 | Books | 2023-03-16 | 2023-05-28 |
726 | Premium | 2023-05-28 | 2023-10-10 |
855 | Books | 2023-04-05 | 2023-05-28 |
855 | Premium | 2023-05-28 | 2023-07-25 |
900 | Books | 2023-01-01 | 2023-12-31 |
SELECT 23