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 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
id | user_id | book_id | stock | user_name | book_name |
---|---|---|---|---|---|
1 | 1 | 1 | 100 | Ryan | Some book Part 1 |
2 | 1 | 2 | 200 | Ryan | syche |
3 | 2 | 1 | 200 | Michelle | Some book Part 1 |
SELECT 3
INSERT 0 1
id | user_id | book_id | stock | user_name | book_name |
---|---|---|---|---|---|
3 | 2 | 1 | 200 | Michelle | Some book Part 1 |
4 | 1 | 3 | 500 | Ryan | My new book 1 |
1 | 1 | 1 | 500 | Ryan | Some book Part 1 |
2 | 1 | 2 | 500 | Ryan | syche |
SELECT 4