| Limit (cost=196.43..196.44 rows=1 width=165) |
| -> Sort (cost=196.43..196.44 rows=1 width=165) |
| Sort Key: "*SELECT* 1".bill_date DESC, "*SELECT* 1".object_type, "*SELECT* 1".object_id DESC, "*SELECT* 1".event_type, "*SELECT* 1".event_id DESC |
| -> Nested Loop Left Join (cost=5.49..196.42 rows=1 width=165) |
| Join Filter: ((g.object_type = "*SELECT* 1".object_type) AND (g.object_id = "*SELECT* 1".object_id) AND (g.event_type = "*SELECT* 1".event_type) AND (g.event_id = "*SELECT* 1".event_id)) |
| Filter: ((g.success_count IS NULL) OR (g.success_count = 0)) |
| -> Append (cost=1.33..190.31 rows=2 width=116) |
| -> Subquery Scan on "*SELECT* 1" (cost=1.33..24.71 rows=1 width=116) |
| Filter: (("*SELECT* 1".object_type <> ALL ('{20,20018}'::integer[])) OR "*SELECT* 1".have_invoice OR (SubPlan 1)) |
| -> Hash Join (cost=1.33..4.07 rows=1 width=116) |
| Hash Cond: (t.id = e.erp_other_payment_ticket_id) |
| -> Seq Scan on tbl_erp_other_payment_tickets t (cost=0.00..2.56 rows=44 width=45) |
| Filter: (status = ANY ('{2,5}'::integer[])) |
| -> Hash (cost=1.32..1.32 rows=1 width=25) |
| -> Seq Scan on tbl_erp_other_payment_ticket_bank_ins e (cost=0.00..1.32 rows=1 width=25) |
| Filter: ((settle_at IS NOT NULL) AND (amount > '0'::numeric) AND (settle_at >= '2026-07-01 00:00:00+08'::timestamp with time zone) AND (settle_at <= '2026-07-31 23:59:59+08'::timestamp with time zone) AND (amount > '0'::numeric)) |
| SubPlan 1 |
| -> Nested Loop (cost=0.29..20.63 rows=1 width=0) |
| Join Filter: (r.taxonomy_id = tt.id) |
| -> Index Scan using tbl_term_taxonomy_relationships_object_id_term_id_idx on tbl_term_taxonomy_relationships r (cost=0.29..11.58 rows=1 width=4) |
| Index Cond: ((object_id = "*SELECT* 1".object_id) AND (term_id = 18)) |
| Filter: ((("*SELECT* 1".object_type = 20) AND (object_type = 7)) OR (("*SELECT* 1".object_type = 20018) AND (object_type = 11))) |
| -> Seq Scan on tbl_term_taxonomies tt (cost=0.00..8.99 rows=5 width=4) |
| Filter: ((serial_no)::text = ANY ('{221106,640301,640302,640303,600704}'::text[])) |
| -> Subquery Scan on "*SELECT* 2" (cost=144.92..165.59 rows=1 width=117) |
| Filter: (("*SELECT* 2".object_type <> ALL ('{20,20018}'::integer[])) OR "*SELECT* 2".have_invoice OR (SubPlan 1)) |
| -> GroupAggregate (cost=144.92..144.95 rows=1 width=117) |
| Group Key: s.id, t_1.id, p.bank_settle_at |
| -> Sort (cost=144.92..144.92 rows=1 width=67) |
| Sort Key: s.id, t_1.id, p.bank_settle_at |
| -> Nested Loop (cost=138.05..144.91 rows=1 width=67) |
| -> Hash Right Join (cost=137.91..144.74 rows=1 width=26) |
| Hash Cond: (bo.erp_payment_ticket_id = p.id) |
| -> Seq Scan on tbl_erp_payment_ticket_bank_outs bo (cost=0.00..5.78 rows=278 width=8) |
| -> Hash (cost=137.90..137.90 rows=1 width=26) |
| -> Hash Join (cost=80.21..137.90 rows=1 width=26) |
| Hash Cond: (s.erp_payment_ticket_id = p.id) |
| -> Seq Scan on tbl_erp_payment_ticket_settles s (cost=0.00..51.48 rows=2364 width=18) |
| Filter: ((amount > '0'::numeric) AND (amount > '0'::numeric)) |
| -> Hash (cost=80.20..80.20 rows=1 width=12) |
| -> Seq Scan on tbl_erp_payment_tickets p (cost=0.00..80.20 rows=1 width=12) |
| Filter: (is_payment_settle AND (bank_settle_at IS NOT NULL) AND (status = ANY ('{2,5}'::integer[])) AND (bank_settle_at >= '2026-07-01 00:00:00+08'::timestamp with time zone) AND (bank_settle_at <= '2026-07-31 23:59:59+08'::timestamp with time zone)) |
| -> Index Scan using tbl_erp_other_payment_tickets_pkey on tbl_erp_other_payment_tickets t_1 (cost=0.14..0.16 rows=1 width=45) |
| Index Cond: (id = s.erp_other_payment_ticket_id) |
| -> Materialize (cost=4.16..4.88 rows=26 width=36) |
| -> Subquery Scan on g (cost=4.16..4.75 rows=26 width=36) |
| -> HashAggregate (cost=4.16..4.49 rows=26 width=36) |
| Group Key: v.object_type, v.object_id, COALESCE((v.event_type)::integer, 0), COALESCE(v.event_id, 0) |
| -> Seq Scan on tbl_voucher_gen_items v (cost=0.00..2.81 rows=54 width=22) |
| Filter: (ledger_id = 1) |