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 apts (
tslot varchar(10),
Data1 int, Data2 int);
insert into apts values
('08:00', 1234, 6758),
('08:10', 5768, 4658),
('09:00', 6754, 8674);
3 rows affected
create table slots( tim varchar(10));
insert into slots values
('08:00'),('08:10'),('08:20'),
('08:30'),('08:40'),('08:50'),
('09:00');
7 rows affected
select tim slot,data1,data2
from apts
right join slots on tslot = tim;
slot | data1 | data2 |
---|---|---|
08:00 | 1234 | 6758 |
08:10 | 5768 | 4658 |
08:20 | null | null |
08:30 | null | null |
08:40 | null | null |
08:50 | null | null |
09:00 | 6754 | 8674 |