QUERY PLAN
Sort (cost=792.15..792.41 rows=104 width=94)
Sort Key: "*SELECT* 1".id DESC
-> Result (cost=83.94..788.67 rows=104 width=94)
-> Append (cost=83.94..787.63 rows=104 width=62)
-> Subquery Scan on "*SELECT* 1" (cost=83.94..152.95 rows=25 width=42)
-> Hash Join (cost=83.94..152.70 rows=25 width=98)
Hash Cond: (t.id = r.erp_collect_ticket_id)
-> Seq Scan on tbl_erp_collect_tickets t (cost=0.00..60.76 rows=2015 width=4)
Filter: (status = ANY ('{2,5,1}'::integer[]))
-> Hash (cost=83.63..83.63 rows=25 width=18)
-> Seq Scan on tbl_erp_collect_ticket_settles r (cost=0.00..83.63 rows=25 width=18)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{3392,3364,3348,3363,3388,3415,3384,3426,3502,3525,3537,3549,3550,3493,3620,3598,3661,3703,3724,3725}'::integer[])))
-> Subquery Scan on "*SELECT* 2" (cost=0.28..538.36 rows=78 width=68)
-> Nested Loop (cost=0.28..537.58 rows=78 width=124)
-> 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 ('{3392,3364,3348,3363,3388,3415,3384,3426,3502,3525,3537,3549,3550,3493,3620,3598,3661,3703,3724,3725}'::integer[])))
-> Index Scan using tbl_erp_cash_cost_tickets_pkey on tbl_erp_cash_cost_tickets t_1 (cost=0.28..6.41 rows=1 width=4)
Index Cond: (id = r_1.erp_cash_cost_ticket_id)
Filter: (status = ANY ('{2,5,1}'::integer[]))
-> Subquery Scan on "*SELECT* 3" (cost=0.28..96.32 rows=1 width=68)
-> Nested Loop (cost=0.28..96.31 rows=1 width=124)
-> Seq Scan on tbl_erp_payment_ticket_settles r_2 (cost=0.00..87.99 rows=1 width=18)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{3392,3364,3348,3363,3388,3415,3384,3426,3502,3525,3537,3549,3550,3493,3620,3598,3661,3703,3724,3725}'::integer[])))
-> Index Scan using tbl_erp_payment_tickets_pkey on tbl_erp_payment_tickets t_2 (cost=0.28..8.30 rows=1 width=4)
Index Cond: (id = r_2.erp_payment_ticket_id)
Filter: (status = ANY ('{2,5,1}'::integer[]))