QUERY PLAN
Aggregate (cost=2633.98..2633.99 rows=1 width=8)
-> Sort (cost=2618.98..2621.48 rows=1000 width=1588)
Sort Key: (date(tt.dt)) DESC
-> HashAggregate (cost=2556.65..2569.15 rows=1000 width=1588)
Group Key: tt.dt, p.day_at, p.user_id
-> Hash Left Join (cost=2536.40..2549.15 rows=1000 width=16)
Hash Cond: (date(tt.dt) = p.day_at)
-> Function Scan on generate_series tt (cost=0.02..10.02 rows=1000 width=8)
-> Hash (cost=2518.89..2518.89 rows=1400 width=8)
-> Seq Scan on tbl_punch p (cost=0.00..2518.89 rows=1400 width=8)
Filter: (user_id = 1001)