QUERY PLAN
Limit (cost=20.00..20.01 rows=1 width=99)
-> Sort (cost=20.00..20.01 rows=1 width=99)
Sort Key: r.created_at DESC
-> Group (cost=19.98..19.99 rows=1 width=99)
Group Key: r.id
-> Sort (cost=19.98..19.99 rows=1 width=99)
Sort Key: r.id
-> Nested Loop Left Join (cost=12.25..19.97 rows=1 width=99)
Join Filter: (crvr.punch_repair_id = r.id)
-> Hash Right Join (cost=12.25..18.88 rows=1 width=99)
Hash Cond: (rccr.punch_repair_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 = 1000) OR (rvr.user_id = 1000))
-> Seq Scan on tbl_punch_repair_carbon_copy_rels rccr (cost=0.00..5.33 rows=333 width=8)
-> Hash (cost=12.24..12.24 rows=1 width=103)
-> Hash Right Join (cost=7.39..12.24 rows=1 width=103)
Hash Cond: (rvr.punch_repair_id = r.id)
-> Seq Scan on tbl_punch_repair_verify_rels rvr (cost=0.00..4.25 rows=225 width=8)
-> Hash (cost=7.38..7.38 rows=1 width=99)
-> Seq Scan on tbl_punch_repairs r (cost=0.00..7.38 rows=1 width=99)
Filter: ((created_at >= '2025-07-01 00:00:00+08'::timestamp with time zone) AND (created_at <= '2025-07-31 23:59:59+08'::timestamp with time zone))
-> Seq Scan on tbl_punch_repair_cancel_verify_rels crvr (cost=0.00..1.04 rows=4 width=4)