add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
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 a (
id text
);

INSERT INTO a VALUES ('A'), ('B'), ('C');

CREATE TABLE b (
id text,
val int
);

INSERT INTO b VALUES ('A',4), ('B', 5), ('B', 6), ('C', 7);

CREATE TABLE c (
id text,
val int
);

INSERT INTO c VALUES ('A', 7), ('B', 8), ('C', 9)
3 rows affected
4 rows affected
3 rows affected
SELECT
a.id,
b.val,
NULL
FROM
a
LEFT JOIN b ON a.id = b.id

UNION ALL

SELECT
a.id,
NULL,
c.val
FROM
a
LEFT JOIN c ON a.id = c.id

ORDER BY 1,2,3
id val ?column?
A 4 null
A null 7
B 5 null
B 6 null
B null 8
C 7 null
C null 9