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?.
select version();
version
PostgreSQL 16.0 (Debian 16.0-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
SELECT 1
create table my_data (
id integer,
value text,
start_date date,
end_date date
);
insert into my_data values
(1,'ABC', '2024-01-29', '2024-02-01'),
(2,'XYZ', '2024-02-28', '2024-03-01');

CREATE TABLE
INSERT 0 2
select
d.id,
d.value,
gs::DATE
from my_data d,
lateral generate_series(d.start_date, d.end_date, '1 day') gs


id value gs
1 ABC 2024-01-29
1 ABC 2024-01-30
1 ABC 2024-01-31
1 ABC 2024-02-01
2 XYZ 2024-02-28
2 XYZ 2024-02-29
2 XYZ 2024-03-01
SELECT 7