QUERY PLAN
Append (cost=55.58..59.43 rows=2 width=240)
-> GroupAggregate (cost=55.58..55.61 rows=1 width=229)
Group Key: r.id
-> Sort (cost=55.58..55.58 rows=1 width=99)
Sort Key: r.id
-> Nested Loop (cost=0.28..55.57 rows=1 width=99)
-> Seq Scan on tbl_erp_payment_ticket_settles t (cost=0.00..47.26 rows=1 width=10)
Filter: (erp_cost_ticket_id = 57)
-> Index Scan using tbl_erp_payment_tickets_pkey on tbl_erp_payment_tickets r (cost=0.28..8.30 rows=1 width=93)
Index Cond: (id = t.erp_payment_ticket_id)
Filter: (status = ANY ('{2,5}'::integer[]))
-> GroupAggregate (cost=3.77..3.80 rows=1 width=250)
Group Key: r_1.id
-> Sort (cost=3.77..3.78 rows=1 width=141)
Sort Key: r_1.id
-> Hash Join (cost=1.11..3.76 rows=1 width=141)
Hash Cond: (r_1.id = t_1.erp_other_income_ticket_id)
-> Seq Scan on tbl_erp_other_income_tickets r_1 (cost=0.00..2.50 rows=38 width=109)
Filter: (status = ANY ('{2,5}'::integer[]))
-> Hash (cost=1.10..1.10 rows=1 width=36)
-> Seq Scan on tbl_erp_other_income_ticket_purchase_contract_settles t_1 (cost=0.00..1.10 rows=1 width=36)
Filter: (erp_cost_ticket_id = 57)