QUERY PLAN
Sort (cost=295.41..295.47 rows=25 width=80)
Sort Key: "*SELECT* 1".id DESC
-> Result (cost=82.80..294.83 rows=25 width=80)
-> Append (cost=82.80..294.58 rows=25 width=48)
-> Subquery Scan on "*SELECT* 1" (cost=82.80..150.19 rows=23 width=46)
-> Hash Join (cost=82.80..149.96 rows=23 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=82.51..82.51 rows=23 width=18)
-> Seq Scan on tbl_erp_collect_ticket_settles r (cost=0.00..82.51 rows=23 width=18)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{4075,4024,4043,4027,4035,4026,4065,4064,4049,4047,4055,4061,4054,4050,4048,4068,4020,4071,4044,4029}'::integer[])))
-> Subquery Scan on "*SELECT* 2" (cost=12.65..50.17 rows=1 width=72)
-> Hash Join (cost=12.65..50.16 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..37.30 rows=78 width=44)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{4075,4024,4043,4027,4035,4026,4065,4064,4049,4047,4055,4061,4054,4050,4048,4068,4020,4071,4044,4029}'::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..94.22 rows=1 width=72)
-> Nested Loop (cost=0.28..94.21 rows=1 width=124)
-> Seq Scan on tbl_erp_payment_ticket_settles r_2 (cost=0.00..85.89 rows=1 width=18)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{4075,4024,4043,4027,4035,4026,4065,4064,4049,4047,4055,4061,4054,4050,4048,4068,4020,4071,4044,4029}'::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[]))