> Laurenz Albe <laurenz.albe@xxxxxxxxxxx> writes: > > "generate_series" has a support function from v12 on: > True, but I don't think it can do anything with non-constant inputs, > as we have in the OP's case. As confirmed by this: https://dbfiddle.uk/?rdbms=postgres_12&fiddle=d0b70717faca3b094be8b4a096758b94 Plan: ============== Sort (cost=623.22..640.72 rows=7000 width=10) (actual time=0.067..0.070 rows=42 loops=1) Sort Key: id, (((generate_series((start_date)::timestamp with time zone, (end_date)::timestamp with time zone, '1 day'::interval)))::date) Sort Method: quicksort Memory: 26kB Buffers: shared hit=1 -> Result (cost=0.00..176.16 rows=7000 width=10) (actual time=0.014..0.045 rows=42 loops=1) Buffers: shared hit=1 -> ProjectSet (cost=0.00..36.16 rows=7000 width=14) (actual time=0.013..0.033 rows=42 loops=1) CUT ============== It goes for the full 7,000 even after a VACUUM FULL VERBOSE ANALYZE test; Pól... > regards, tom lane