QUERY PLAN
Sort (cost=234.11..234.15 rows=13 width=140)
Sort Key: "*SELECT* 1".id DESC
-> Result (cost=57.82..233.87 rows=13 width=140)
-> Append (cost=57.82..233.74 rows=13 width=98)
-> Subquery Scan on "*SELECT* 1" (cost=57.82..124.88 rows=11 width=94)
-> Hash Join (cost=57.82..124.77 rows=11 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=48)
Filter: (status = ANY ('{2,5,1}'::integer[]))
-> Hash (cost=57.68..57.68 rows=11 width=18)
-> Seq Scan on tbl_erp_collect_ticket_settles r (cost=0.00..57.68 rows=11 width=18)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{4075,4071,4068,4065,4064,4055,4054,4050,4049,4061}'::integer[])))
-> Subquery Scan on "*SELECT* 2" (cost=12.65..40.32 rows=1 width=120)
-> Hash Join (cost=12.65..40.31 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..27.55 rows=39 width=44)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{4075,4071,4068,4065,4064,4055,4054,4050,4049,4061}'::integer[])))
-> Hash (cost=12.61..12.61 rows=3 width=48)
-> Seq Scan on tbl_erp_cash_cost_tickets t_1 (cost=0.00..12.61 rows=3 width=48)
Filter: (status = ANY ('{2,5,1}'::integer[]))
-> Subquery Scan on "*SELECT* 3" (cost=0.28..68.54 rows=1 width=120)
-> Nested Loop (cost=0.28..68.53 rows=1 width=124)
-> Seq Scan on tbl_erp_payment_ticket_settles r_2 (cost=0.00..60.21 rows=1 width=18)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{4075,4071,4068,4065,4064,4055,4054,4050,4049,4061}'::integer[])))
-> Index Scan using tbl_erp_payment_tickets_pkey on tbl_erp_payment_tickets t_2 (cost=0.28..8.30 rows=1 width=48)
Index Cond: (id = r_2.erp_payment_ticket_id)
Filter: (status = ANY ('{2,5,1}'::integer[]))