QUERY PLAN
Sort (cost=1859.57..1862.07 rows=1000 width=363)
Sort Key: (date(tt.dt)) DESC
-> HashAggregate (cost=1792.24..1809.74 rows=1000 width=363)
Group Key: tt.dt, p.day_at, p.user_id
-> Hash Left Join (cost=1771.99..1784.74 rows=1000 width=347)
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=339)
-> Bitmap Heap Scan on tbl_punch p (cost=1067.88..1768.66 rows=265 width=339)
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)