QUERY PLAN
Sort (cost=791.97..792.22 rows=102 width=94)
Sort Key: "*SELECT* 1".id DESC
-> Result (cost=83.92..788.57 rows=102 width=94)
-> Append (cost=83.92..787.55 rows=102 width=62)
-> Subquery Scan on "*SELECT* 1" (cost=83.92..152.87 rows=23 width=42)
-> Hash Join (cost=83.92..152.64 rows=23 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=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 ('{3883,4071,3914,3916,3911,3965,4009,3789,4016,4130,4132,4131,4112,4111,4135,4136,4137,4138,4140,4139}'::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 ('{3883,4071,3914,3916,3911,3965,4009,3789,4016,4130,4132,4131,4112,4111,4135,4136,4137,4138,4140,4139}'::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 ('{3883,4071,3914,3916,3911,3965,4009,3789,4016,4130,4132,4131,4112,4111,4135,4136,4137,4138,4140,4139}'::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[]))