QUERY PLAN
Sort (cost=483.54..483.68 rows=57 width=170)
Sort Key: "*SELECT* 1".id DESC
-> Result (cost=60.40..481.87 rows=57 width=170)
-> Append (cost=60.40..481.30 rows=57 width=112)
-> Subquery Scan on "*SELECT* 1" (cost=60.40..127.57 rows=13 width=94)
-> Hash Join (cost=60.40..127.44 rows=13 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=60.24..60.24 rows=13 width=18)
-> Seq Scan on tbl_erp_collect_ticket_settles r (cost=0.00..60.24 rows=13 width=18)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{2909,2261,2326,2327,1012,2182,2566,2565,2627,2626,2564}'::integer[])))
-> Subquery Scan on "*SELECT* 2" (cost=0.28..282.34 rows=43 width=118)
-> Nested Loop (cost=0.28..281.91 rows=43 width=122)
-> Seq Scan on tbl_erp_cash_cost_ticket_sales_contract_settles r_1 (cost=0.00..28.52 rows=43 width=44)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{2909,2261,2326,2327,1012,2182,2566,2565,2627,2626,2564}'::integer[])))
-> Index Scan using tbl_erp_cash_cost_tickets_pkey on tbl_erp_cash_cost_tickets t_1 (cost=0.28..5.89 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..71.40 rows=1 width=89)
-> Nested Loop (cost=0.28..71.39 rows=1 width=93)
-> Seq Scan on tbl_erp_payment_ticket_settles r_2 (cost=0.00..63.07 rows=1 width=18)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{2909,2261,2326,2327,1012,2182,2566,2565,2627,2626,2564}'::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[]))