QUERY PLAN
Limit (cost=89.46..89.46 rows=1 width=211)
-> Sort (cost=89.46..89.46 rows=1 width=211)
Sort Key: (CASE WHEN (r.status = ANY ('{1,5}'::integer[])) THEN 0 ELSE 1 END), r.created_at DESC
-> HashAggregate (cost=89.44..89.45 rows=1 width=211)
Group Key: r.id
-> Hash Join (cost=37.67..65.19 rows=9700 width=207)
Hash Cond: (r.id = rccr.punch_overtime_id)
-> Hash Right Join (cost=2.05..25.43 rows=970 width=207)
Hash Cond: (crvr.punch_overtime_id = r.id)
-> Seq Scan on tbl_punch_overtime_cancel_verify_rels crvr (cost=0.00..19.70 rows=970 width=4)
-> Hash (cost=2.03..2.03 rows=1 width=207)
-> Nested Loop Left Join (cost=0.00..2.03 rows=1 width=207)
Join Filter: (rvr.punch_overtime_id = r.id)
-> Seq Scan on tbl_punch_overtimes r (cost=0.00..1.01 rows=1 width=207)
-> Seq Scan on tbl_punch_overtime_verify_rels rvr (cost=0.00..1.01 rows=1 width=4)
-> Hash (cost=35.50..35.50 rows=10 width=4)
-> Seq Scan on tbl_punch_overtime_carbon_copy_rels rccr (cost=0.00..35.50 rows=10 width=4)
Filter: (user_id = 1000)