QUERY PLAN
Sort (cost=240.30..240.34 rows=15 width=81)
Sort Key: "*SELECT* 1".id DESC
-> Result (cost=60.33..240.01 rows=15 width=81)
-> Append (cost=60.33..239.86 rows=15 width=49)
-> Subquery Scan on "*SELECT* 1" (cost=60.33..127.44 rows=13 width=46)
-> Hash Join (cost=60.33..127.31 rows=13 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=60.17..60.17 rows=13 width=18)
-> Seq Scan on tbl_erp_collect_ticket_settles r (cost=0.00..60.17 rows=13 width=18)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{4078,4075,195,4024,4055,4061,4068,4020,4071,4044,2351}'::integer[])))
-> Subquery Scan on "*SELECT* 2" (cost=12.65..41.31 rows=1 width=72)
-> Hash Join (cost=12.65..41.30 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..28.52 rows=43 width=44)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{4078,4075,195,4024,4055,4061,4068,4020,4071,4044,2351}'::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..71.11 rows=1 width=72)
-> Nested Loop (cost=0.28..71.10 rows=1 width=124)
-> Seq Scan on tbl_erp_payment_ticket_settles r_2 (cost=0.00..62.78 rows=1 width=18)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{4078,4075,195,4024,4055,4061,4068,4020,4071,4044,2351}'::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[]))