QUERY PLAN
Aggregate (cost=156.96..156.97 rows=1 width=32)
-> Nested Loop (cost=41.55..156.95 rows=3 width=6)
-> Hash Join (cost=41.41..154.56 rows=3 width=10)
Hash Cond: (t.id = r.erp_payment_ticket_id)
-> Seq Scan on tbl_erp_payment_tickets t (cost=0.00..109.27 rows=257 width=4)
Filter: ((bank_settle_at <= '2026-06-30 23:59:59+08'::timestamp with time zone) AND (status = 2))
-> Hash (cost=41.01..41.01 rows=32 width=14)
-> Seq Scan on tbl_erp_payment_ticket_settles r (cost=0.00..41.01 rows=32 width=14)
Filter: (erp_other_payment_ticket_id IS NOT NULL)
-> Index Scan using tbl_erp_other_payment_tickets_pkey on tbl_erp_other_payment_tickets op (cost=0.14..0.79 rows=1 width=4)
Index Cond: (id = r.erp_other_payment_ticket_id)
Filter: (ticket_type = ANY ('{1,2,4}'::integer[]))