QUERY PLAN
Limit (cost=27.88..27.89 rows=1 width=211)
-> Sort (cost=27.88..27.89 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=27.86..27.87 rows=1 width=211)
Group Key: r.id
-> Hash Right Join (cost=2.05..25.44 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.04..2.04 rows=1 width=207)
-> Nested Loop Left Join (cost=0.00..2.04 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)
Filter: (created_by = 1000)
-> Seq Scan on tbl_punch_overtime_verify_rels rvr (cost=0.00..1.01 rows=1 width=4)