QUERY PLAN
Append (cost=53.88..58.41 rows=2 width=240)
-> GroupAggregate (cost=53.88..53.91 rows=1 width=229)
Group Key: r.id
-> Sort (cost=53.88..53.88 rows=1 width=99)
Sort Key: r.id
-> Nested Loop (cost=0.28..53.87 rows=1 width=99)
-> Seq Scan on tbl_erp_payment_ticket_settles t (cost=0.00..45.56 rows=1 width=10)
Filter: (erp_cost_ticket_id = 58)
-> 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=4.45..4.48 rows=1 width=250)
Group Key: r_1.id
-> Sort (cost=4.45..4.45 rows=1 width=115)
Sort Key: r_1.id
-> Hash Join (cost=1.15..4.44 rows=1 width=115)
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..3.00 rows=74 width=109)
Filter: (status = ANY ('{2,5}'::integer[]))
-> Hash (cost=1.14..1.14 rows=1 width=10)
-> Seq Scan on tbl_erp_other_income_ticket_purchase_contract_settles t_1 (cost=0.00..1.14 rows=1 width=10)
Filter: (erp_cost_ticket_id = 58)