QUERY PLAN
Limit (cost=78.23..78.23 rows=1 width=198)
-> Sort (cost=78.13..78.23 rows=42 width=198)
Sort Key: c.serial_no, c.id, (0), (0), (0), (0)
-> Append (cost=20.01..76.99 rows=42 width=198)
-> Hash Left Join (cost=20.01..32.17 rows=41 width=198)
Hash Cond: (c.id = ca.ledger_account_caption_id)
-> Hash Anti Join (cost=12.87..23.79 rows=41 width=33)
Hash Cond: ((c.ledger_id = child.ledger_id) AND (c.id = child.parent_id))
-> Seq Scan on tbl_ledger_account_captions c (cost=0.00..10.21 rows=44 width=37)
Filter: ((NOT is_delete) AND (NOT COALESCE(is_auxiliary_customer, false)) AND (NOT COALESCE(is_auxiliary_supplier, false)) AND (ledger_id = 1))
-> Hash (cost=10.21..10.21 rows=177 width=8)
-> Seq Scan on tbl_ledger_account_captions child (cost=0.00..10.21 rows=177 width=8)
Filter: ((NOT is_delete) AND (ledger_id = 1))
-> Hash (cost=6.87..6.87 rows=22 width=68)
-> Subquery Scan on ca (cost=6.32..6.87 rows=22 width=68)
-> HashAggregate (cost=6.32..6.65 rows=22 width=68)
Group Key: i.ledger_account_caption_id
-> Hash Join (cost=2.04..5.48 rows=112 width=12)
Hash Cond: (i.ledger_ticket_id = t.id)
-> Seq Scan on tbl_ledger_ticket_items i (cost=0.00..3.12 rows=112 width=16)
Filter: (ledger_account_caption_id IS NOT NULL)
-> Hash (cost=1.57..1.57 rows=38 width=4)
-> Seq Scan on tbl_ledger_tickets t (cost=0.00..1.57 rows=38 width=4)
Filter: ((ledger_id = 1) AND (status = 1))
-> Nested Loop Anti Join (cost=5.16..44.41 rows=1 width=198)
Join Filter: ((child_1.ledger_id = c_1.ledger_id) AND (child_1.parent_id = c_1.id))
-> Nested Loop Left Join (cost=5.16..31.50 rows=1 width=442)
Join Filter: ((i_1.ledger_account_caption_id = c_1.id) AND (i_1.auxiliary_item_id = a.id))
-> Nested Loop Left Join (cost=0.29..26.58 rows=1 width=378)
Join Filter: (o.auxiliary_item_id = a.id)
-> Nested Loop (cost=0.14..18.39 rows=1 width=346)
Join Filter: ((c_1.is_auxiliary_customer AND (a.type = 1)) OR (c_1.is_auxiliary_supplier AND (a.type = 2)))
-> Seq Scan on tbl_ledger_account_captions c_1 (cost=0.00..10.21 rows=1 width=36)
Filter: ((NOT is_delete) AND (is_auxiliary_customer OR is_auxiliary_supplier) AND (ledger_id = 1))
-> Index Scan using idx_tbl_ledger_auxiliary_items_ledger_serial_no on tbl_ledger_auxiliary_items a (cost=0.14..8.17 rows=1 width=316)
Index Cond: (ledger_id = 1)
Filter: ((NOT is_delete) AND ((type = 1) OR (type = 2)))
-> Index Scan using idx_tbl_ledger_auxiliary_opening_balances_unique_item on tbl_ledger_auxiliary_opening_balances o (cost=0.15..8.17 rows=1 width=44)
Index Cond: ((ledger_id = c_1.ledger_id) AND (ledger_id = 1) AND (ledger_account_caption_id = c_1.id))
-> GroupAggregate (cost=4.87..4.89 rows=1 width=72)
Group Key: i_1.ledger_account_caption_id, i_1.auxiliary_item_id
-> Sort (cost=4.87..4.87 rows=1 width=16)
Sort Key: i_1.ledger_account_caption_id, i_1.auxiliary_item_id
-> Hash Join (cost=3.13..4.86 rows=1 width=16)
Hash Cond: (t_1.id = i_1.ledger_ticket_id)
-> Seq Scan on tbl_ledger_tickets t_1 (cost=0.00..1.57 rows=38 width=4)
Filter: ((ledger_id = 1) AND (status = 1))
-> Hash (cost=3.12..3.12 rows=1 width=20)
-> Seq Scan on tbl_ledger_ticket_items i_1 (cost=0.00..3.12 rows=1 width=20)
Filter: ((ledger_account_caption_id IS NOT NULL) AND (auxiliary_item_id IS NOT NULL))
-> Seq Scan on tbl_ledger_account_captions child_1 (cost=0.00..10.21 rows=177 width=8)
Filter: ((NOT is_delete) AND (ledger_id = 1))