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
a | b | c |
---|---|---|
1 | 2 | 22 |
1 | 3 | 34 |
2 | 3 | 26 |
INSERT 0 3
pkey | c |
---|---|
1 | 22 |
2 | 22 |
3 | 22 |
4 | 34 |
5 | 26 |
6 | 26 |
INSERT 0 6
ERROR: duplicate key value violates unique constraint "available_combinations_a_b_key" DETAIL: Key (a, b)=(1, 2) already exists.
ERROR: duplicate key value violates unique constraint "available_combinations_c_key" DETAIL: Key (c)=(34) already exists.
ERROR: duplicate key value violates unique constraint "available_combinations_c_key" DETAIL: Key (c)=(22) already exists.
INSERT 0 4
a | b | c |
---|---|---|
1 | 2 | 22 |
1 | 3 | 34 |
2 | 3 | 26 |
7 | 8 | 33 |
7 | 9 | 35 |
8 | 7 | 36 |
8 | 8 | 37 |
SELECT 7
INSERT 0 10
pkey | c |
---|---|
1 | 22 |
2 | 22 |
3 | 22 |
4 | 34 |
5 | 26 |
6 | 26 |
7 | 33 |
8 | 33 |
9 | 35 |
10 | 35 |
11 | 35 |
12 | 35 |
13 | 36 |
14 | 36 |
15 | 37 |
16 | 37 |
SELECT 16
pkey | a | b | c |
---|---|---|---|
1 | 1 | 2 | 22 |
2 | 1 | 2 | 22 |
3 | 1 | 2 | 22 |
4 | 1 | 3 | 34 |
5 | 2 | 3 | 26 |
6 | 2 | 3 | 26 |
7 | 7 | 8 | 33 |
8 | 7 | 8 | 33 |
9 | 7 | 9 | 35 |
10 | 7 | 9 | 35 |
11 | 7 | 9 | 35 |
12 | 7 | 9 | 35 |
13 | 8 | 7 | 36 |
14 | 8 | 7 | 36 |
15 | 8 | 8 | 37 |
16 | 8 | 8 | 37 |
SELECT 16