QUERY PLAN
Sort (cost=624.66..624.91 rows=102 width=170)
Sort Key: "*SELECT* 1".id DESC
-> Result (cost=82.90..621.26 rows=102 width=170)
-> Append (cost=82.90..620.24 rows=102 width=112)
-> Subquery Scan on "*SELECT* 1" (cost=82.90..150.34 rows=23 width=94)
-> Hash Join (cost=82.90..150.11 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.35 rows=1989 width=48)
Filter: (status = ANY ('{2,5,1}'::integer[]))
-> Hash (cost=82.62..82.62 rows=23 width=18)
-> Seq Scan on tbl_erp_collect_ticket_settles r (cost=0.00..82.62 rows=23 width=18)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{4024,4022,4021,4020,4028,4027,4009,4005,4002,4016,4008,3998,3997,3995,3993,3989,3984,3980,3979,3978}'::integer[])))
-> Subquery Scan on "*SELECT* 2" (cost=38.28..375.25 rows=78 width=118)
-> Hash Join (cost=38.28..374.47 rows=78 width=122)
Hash Cond: (t_1.id = r_1.erp_cash_cost_ticket_id)
-> Seq Scan on tbl_erp_cash_cost_tickets t_1 (cost=0.00..243.49 rows=7308 width=46)
Filter: (status = ANY ('{2,5,1}'::integer[]))
-> Hash (cost=37.30..37.30 rows=78 width=44)
-> 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 ('{4024,4022,4021,4020,4028,4027,4009,4005,4002,4016,4008,3998,3997,3995,3993,3989,3984,3980,3979,3978}'::integer[])))
-> Subquery Scan on "*SELECT* 3" (cost=0.28..94.64 rows=1 width=89)
-> Nested Loop (cost=0.28..94.63 rows=1 width=93)
-> Seq Scan on tbl_erp_payment_ticket_settles r_2 (cost=0.00..86.31 rows=1 width=18)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{4024,4022,4021,4020,4028,4027,4009,4005,4002,4016,4008,3998,3997,3995,3993,3989,3984,3980,3979,3978}'::integer[])))
-> Index Scan using tbl_erp_payment_tickets_pkey on tbl_erp_payment_tickets t_2 (cost=0.28..8.30 rows=1 width=17)
Index Cond: (id = r_2.erp_payment_ticket_id)
Filter: (status = ANY ('{2,5,1}'::integer[]))