QUERY PLAN
Sort (cost=289.53..289.60 rows=27 width=80)
Sort Key: "*SELECT* 1".id DESC
-> Result (cost=80.34..288.89 rows=27 width=80)
-> Append (cost=80.34..288.62 rows=27 width=48)
-> Subquery Scan on "*SELECT* 1" (cost=80.34..147.78 rows=25 width=46)
-> Hash Join (cost=80.34..147.53 rows=25 width=98)
Hash Cond: (t.id = r.erp_collect_ticket_id)
-> Seq Scan on tbl_erp_collect_tickets t (cost=0.00..59.31 rows=1986 width=8)
Filter: (status = ANY ('{2,5,1}'::integer[]))
-> Hash (cost=80.03..80.03 rows=25 width=18)
-> Seq Scan on tbl_erp_collect_ticket_settles r (cost=0.00..80.03 rows=25 width=18)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{4075,3620,3525,3661,3703,3763,3755,3724,3725,3746,3803,3857,3935,3916,3900,3967,3978,3997,4055}'::integer[])))
-> Subquery Scan on "*SELECT* 2" (cost=12.65..49.19 rows=1 width=72)
-> Hash Join (cost=12.65..49.18 rows=1 width=124)
Hash Cond: (r_1.erp_cash_cost_ticket_id = t_1.id)
-> Seq Scan on tbl_erp_cash_cost_ticket_sales_contract_settles r_1 (cost=0.00..36.33 rows=74 width=44)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{4075,3620,3525,3661,3703,3763,3755,3724,3725,3746,3803,3857,3935,3916,3900,3967,3978,3997,4055}'::integer[])))
-> Hash (cost=12.61..12.61 rows=3 width=8)
-> Seq Scan on tbl_erp_cash_cost_tickets t_1 (cost=0.00..12.61 rows=3 width=8)
Filter: (status = ANY ('{2,5,1}'::integer[]))
-> Subquery Scan on "*SELECT* 3" (cost=0.28..91.65 rows=1 width=72)
-> Nested Loop (cost=0.28..91.64 rows=1 width=124)
-> Seq Scan on tbl_erp_payment_ticket_settles r_2 (cost=0.00..83.32 rows=1 width=18)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{4075,3620,3525,3661,3703,3763,3755,3724,3725,3746,3803,3857,3935,3916,3900,3967,3978,3997,4055}'::integer[])))
-> Index Scan using tbl_erp_payment_tickets_pkey on tbl_erp_payment_tickets t_2 (cost=0.28..8.30 rows=1 width=8)
Index Cond: (id = r_2.erp_payment_ticket_id)
Filter: (status = ANY ('{2,5,1}'::integer[]))