QUERY PLAN
Limit (cost=6.47..6.47 rows=1 width=59)
-> Sort (cost=6.47..6.47 rows=1 width=59)
Sort Key: t.ticket_date, t.ticket_word, t.serial_no, t.id
-> Group (cost=6.45..6.46 rows=1 width=59)
Group Key: t.id
-> Sort (cost=6.45..6.46 rows=1 width=59)
Sort Key: t.id
-> Hash Join (cost=4.81..6.44 rows=1 width=59)
Hash Cond: (t.id = ti.ledger_ticket_id)
-> Seq Scan on tbl_ledger_tickets t (cost=0.00..1.48 rows=38 width=59)
Filter: (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)))