QUERY PLAN
Limit (cost=6.66..6.66 rows=1 width=59)
-> Sort (cost=6.66..6.66 rows=1 width=59)
Sort Key: t.ticket_date, t.ticket_word, t.serial_no, t.id
-> Group (cost=6.64..6.65 rows=1 width=59)
Group Key: t.id
-> Sort (cost=6.64..6.65 rows=1 width=59)
Sort Key: t.id
-> Hash Join (cost=4.81..6.63 rows=1 width=59)
Hash Cond: (t.id = ti.ledger_ticket_id)
-> Seq Scan on tbl_ledger_tickets t (cost=0.00..1.67 rows=38 width=59)
Filter: ((ticket_date >= '2026-01-01'::date) AND (ticket_date <= '2026-12-31'::date) AND (ledger_id = 1))
-> Hash (cost=4.80..4.80 rows=1 width=4)
-> Seq Scan on tbl_ledger_ticket_items ti (cost=0.00..4.80 rows=1 width=4)
Filter: (((debit_amount <> '0'::numeric) AND (debit_amount >= '52733'::numeric) AND (debit_amount <= '52734'::numeric)) OR ((credit_amount <> '0'::numeric) AND (credit_amount >= '52733'::numeric) AND (credit_amount <= '52734'::numeric)))