QUERY PLAN
Aggregate (cost=1869.57..1869.58 rows=1 width=8)
-> Sort (cost=1854.57..1857.07 rows=1000 width=1588)
Sort Key: (date(tt.dt)) DESC
-> HashAggregate (cost=1792.24..1804.74 rows=1000 width=1588)
Group Key: tt.dt, p.day_at, p.user_id
-> Hash Left Join (cost=1771.99..1784.74 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=1768.66..1768.66 rows=265 width=8)
-> Bitmap Heap Scan on tbl_punch p (cost=1067.88..1768.66 rows=265 width=8)
Recheck Cond: (user_id = 5440)
-> Bitmap Index Scan on tbl_punch_pkey (cost=0.00..1067.81 rows=265 width=0)
Index Cond: (user_id = 5440)