QUERY PLAN
Sort (cost=791.97..792.22 rows=102 width=168)
Sort Key: "*SELECT* 1".id DESC
-> Result (cost=83.92..788.57 rows=102 width=168)
-> Append (cost=83.92..787.55 rows=102 width=110)
-> Subquery Scan on "*SELECT* 1" (cost=83.92..152.87 rows=23 width=83)
-> Hash Join (cost=83.92..152.64 rows=23 width=87)
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=37)
Filter: (status = ANY ('{2,5,1}'::integer[]))
-> Hash (cost=83.63..83.63 rows=23 width=18)
-> Seq Scan on tbl_erp_collect_ticket_settles r (cost=0.00..83.63 rows=23 width=18)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{4140,4139,4138,4137,4136,4135,4130,4129,4120,4112,4131,4111,4109,4106,4099,4094,4091,4086,4083,4082}'::integer[])))
-> Subquery Scan on "*SELECT* 2" (cost=0.28..538.36 rows=78 width=118)
-> Nested Loop (cost=0.28..537.58 rows=78 width=122)
-> 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 ('{4140,4139,4138,4137,4136,4135,4130,4129,4120,4112,4131,4111,4109,4106,4099,4094,4091,4086,4083,4082}'::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=46)
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=109)
-> Nested Loop (cost=0.28..96.31 rows=1 width=113)
-> 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 ('{4140,4139,4138,4137,4136,4135,4130,4129,4120,4112,4131,4111,4109,4106,4099,4094,4091,4086,4083,4082}'::integer[])))
-> Index Scan using tbl_erp_payment_tickets_pkey on tbl_erp_payment_tickets t_2 (cost=0.28..8.30 rows=1 width=37)
Index Cond: (id = r_2.erp_payment_ticket_id)
Filter: (status = ANY ('{2,5,1}'::integer[]))