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 TABLE
INSERT 0 6
INSERT 0 3
INSERT 0 6
category_id | name |
---|---|
1 | Laptops |
2 | Phones |
3 | Tablets |
SELECT 3
product_id | name |
---|---|
1 | Macbook Pro |
2 | Macbook Air |
3 | iPhone 11 |
4 | Google Pixel 4 |
5 | iPad Mini 4 |
6 | iPad |
SELECT 6
category_id | all_products |
---|---|
1 | 6 |
1 | 6 |
2 | 6 |
2 | 6 |
3 | 6 |
3 | 6 |
SELECT 6
category_id | name | products | all_products |
---|---|---|---|
1 | Laptops | 2 | 6 |
2 | Phones | 2 | 6 |
3 | Tablets | 2 | 6 |
SELECT 3
category_id | name | products | all_products |
---|---|---|---|
2 | Phones | 2 | 6 |
3 | Tablets | 2 | 6 |
1 | Laptops | 2 | 6 |
SELECT 3