QUERY PLAN
Aggregate (cost=83.48..83.49 rows=1 width=8)
-> Nested Loop Left Join (cost=3.23..83.47 rows=1 width=0)
Join Filter: (v.object_id = e.id)
-> Seq Scan on tbl_erp_payment_tickets e (cost=0.00..80.20 rows=1 width=4)
Filter: ((wrote_date >= '2026-07-01'::date) AND (wrote_date <= '2026-07-31'::date) AND (status = 2))
-> GroupAggregate (cost=3.23..3.25 rows=1 width=36)
Group Key: v.object_type, v.object_id, (COALESCE((v.event_type)::integer, 0)), (COALESCE(v.event_id, 0))
-> Sort (cost=3.23..3.23 rows=1 width=16)
Sort Key: v.object_id
-> Seq Scan on tbl_voucher_gen_items v (cost=0.00..3.22 rows=1 width=16)
Filter: ((ledger_id = 1) AND (object_type = 20012) AND (COALESCE(event_id, 0) = 0) AND (COALESCE((event_type)::integer, 0) = 0))