QUERY PLAN
Aggregate (cost=5313.03..5313.04 rows=1 width=8)
-> Sort (cost=5313.01..5313.01 rows=1 width=207)
Sort Key: r.created_at DESC
-> Group (cost=69.86..5313.00 rows=1 width=207)
Group Key: r.id
-> Merge Left Join (cost=69.86..366.00 rows=1978800 width=12)
Merge Cond: (r.id = crvr.punch_overtime_id)
-> Nested Loop Left Join (cost=2.04..144.67 rows=2040 width=12)
Join Filter: (rccr.punch_overtime_id = r.id)
Filter: ((r.created_by = ANY ('{1000,1001,1004,1005,1011,1013,1015,1017,1022,1023,5016,5064,5085,5087,5248,5250,5252,5295,5296,5300,5311,5329,5332,5360,5388,5404,5420,5440,5445,5446}'::integer[])) OR (rccr.user_id = 1001) OR (rvr.user_id = 1001))
-> Merge Left Join (cost=2.04..2.07 rows=1 width=20)
Merge Cond: (r.id = rvr.punch_overtime_id)
-> Sort (cost=1.02..1.03 rows=1 width=16)
Sort Key: r.id
-> Seq Scan on tbl_punch_overtimes r (cost=0.00..1.01 rows=1 width=16)
Filter: (status = '2'::smallint)
-> Sort (cost=1.02..1.02 rows=1 width=8)
Sort Key: rvr.punch_overtime_id
-> Seq Scan on tbl_punch_overtime_verify_rels rvr (cost=0.00..1.01 rows=1 width=8)
-> Seq Scan on tbl_punch_overtime_carbon_copy_rels rccr (cost=0.00..30.40 rows=2040 width=8)
-> Sort (cost=67.82..70.25 rows=970 width=4)
Sort Key: crvr.punch_overtime_id
-> Seq Scan on tbl_punch_overtime_cancel_verify_rels crvr (cost=0.00..19.70 rows=970 width=4)