QUERY PLAN
Aggregate (cost=150.84..150.85 rows=1 width=32)
-> Hash Anti Join (cost=78.66..150.57 rows=109 width=6)
Hash Cond: (t.id = cancel.purchase_contract_id)
-> Seq Scan on tbl_purchase_contracts t (cost=0.00..70.54 rows=109 width=10)
Filter: ((NOT is_draft) AND (NOT is_refuse) AND (created_at >= '2025-08-08 14:34:58+08'::timestamp with time zone))
-> Hash (cost=78.64..78.64 rows=1 width=4)
-> Subquery Scan on cancel (cost=78.62..78.64 rows=1 width=4)
-> GroupAggregate (cost=78.62..78.63 rows=1 width=12)
Group Key: t_1.purchase_contract_id
-> Sort (cost=78.62..78.62 rows=1 width=4)
Sort Key: t_1.purchase_contract_id
-> Seq Scan on tbl_erp_purchase_orders t_1 (cost=0.00..78.61 rows=1 width=4)
Filter: ((cancel_at >= '2025-08-08 14:34:58+08'::timestamp with time zone) AND (cancel_at <= '2025-12-31 23:59:59+08'::timestamp with time zone) AND (status = 8))