QUERY PLAN
Sort (cost=625.02..625.29 rows=106 width=97)
Sort Key: "*SELECT* 1".id DESC
-> Result (cost=82.95..621.46 rows=106 width=97)
-> Append (cost=82.95..620.40 rows=106 width=65)
-> Subquery Scan on "*SELECT* 1" (cost=82.95..150.50 rows=27 width=46)
-> Hash Join (cost=82.95..150.23 rows=27 width=98)
Hash Cond: (t.id = r.erp_collect_ticket_id)
-> Seq Scan on tbl_erp_collect_tickets t (cost=0.00..59.35 rows=1989 width=8)
Filter: (status = ANY ('{2,5,1}'::integer[]))
-> Hash (cost=82.62..82.62 rows=27 width=18)
-> Seq Scan on tbl_erp_collect_ticket_settles r (cost=0.00..82.62 rows=27 width=18)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{4075,4082,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=38.28..375.25 rows=78 width=72)
-> Hash Join (cost=38.28..374.47 rows=78 width=124)
Hash Cond: (t_1.id = r_1.erp_cash_cost_ticket_id)
-> Seq Scan on tbl_erp_cash_cost_tickets t_1 (cost=0.00..243.49 rows=7308 width=8)
Filter: (status = ANY ('{2,5,1}'::integer[]))
-> Hash (cost=37.30..37.30 rows=78 width=44)
-> Seq Scan on tbl_erp_cash_cost_ticket_sales_contract_settles r_1 (cost=0.00..37.30 rows=78 width=44)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{4075,4082,3620,3525,3661,3703,3763,3755,3724,3725,3746,3803,3857,3935,3916,3900,3967,3978,3997,4055}'::integer[])))
-> Subquery Scan on "*SELECT* 3" (cost=0.28..94.64 rows=1 width=72)
-> Nested Loop (cost=0.28..94.63 rows=1 width=124)
-> Seq Scan on tbl_erp_payment_ticket_settles r_2 (cost=0.00..86.31 rows=1 width=18)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{4075,4082,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[]))