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
CREATE TABLE
CREATE VIEW
INSERT 0 1
CREATE FUNCTION
CREATE TRIGGER
product_id | product_name |
---|---|
1 | foo |
SELECT 1
purchase_id | product_name | when_bought |
---|---|---|
1 | foo | 2022-12-26 |
INSERT 0 1
purchase_id | product_name | when_bought |
---|---|---|
2 | bar | 2022-12-26 |
INSERT 0 1
purchase_id | product_id | when_bought |
---|---|---|
1 | 1 | 2022-12-26 |
2 | null | 2022-12-26 |
SELECT 2
CREATE FUNCTION
purchase_id | product_name | when_bought |
---|---|---|
null | bar | 2022-12-26 |
INSERT 0 1
purchase_id | product_id | when_bought |
---|---|---|
1 | 1 | 2022-12-26 |
2 | null | 2022-12-26 |
SELECT 2
CREATE FUNCTION
purchase_id | product_name | when_bought |
---|---|---|
3 | foo | 2022-12-26 |
INSERT 0 1
purchase_id | product_name | when_bought |
---|---|---|
null | bar | 2022-12-26 |
INSERT 0 1
purchase_id | product_id | when_bought |
---|---|---|
1 | 1 | 2022-12-26 |
2 | null | 2022-12-26 |
3 | 1 | 2022-12-26 |
SELECT 3