QUERY PLAN
Sort (cost=273.29..273.36 rows=27 width=80)
Sort Key: "*SELECT* 1".id DESC
-> Result (cost=87.01..272.65 rows=27 width=80)
-> Append (cost=87.01..272.38 rows=27 width=48)
-> Subquery Scan on "*SELECT* 1" (cost=87.01..157.44 rows=25 width=46)
-> Hash Join (cost=87.01..157.19 rows=25 width=98)
Hash Cond: (t.id = r.erp_collect_ticket_id)
-> Seq Scan on tbl_erp_collect_tickets t (cost=0.00..61.74 rows=2136 width=8)
Filter: (status = ANY ('{2,5}'::integer[]))
-> Hash (cost=86.70..86.70 rows=25 width=18)
-> Seq Scan on tbl_erp_collect_ticket_settles r (cost=0.00..86.70 rows=25 width=18)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{2742,2776,2737,3101,2672,2662,3112,3250,3235,3232,3247,3249,2865,2812,2783,2981,2756,2963,2708,2817}'::integer[])))
-> Subquery Scan on "*SELECT* 2" (cost=0.28..9.36 rows=1 width=72)
-> Nested Loop (cost=0.28..9.35 rows=1 width=124)
-> Seq Scan on tbl_erp_cash_cost_ticket_sales_contract_settles r_1 (cost=0.00..1.03 rows=1 width=44)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{2742,2776,2737,3101,2672,2662,3112,3250,3235,3232,3247,3249,2865,2812,2783,2981,2756,2963,2708,2817}'::integer[])))
-> Index Scan using tbl_erp_cash_cost_tickets_pkey on tbl_erp_cash_cost_tickets t_1 (cost=0.28..8.30 rows=1 width=8)
Index Cond: (id = r_1.erp_cash_cost_ticket_id)
Filter: (is_payment_settle AND (status = ANY ('{2,5}'::integer[])))
-> Subquery Scan on "*SELECT* 3" (cost=0.28..105.58 rows=1 width=72)
-> Nested Loop (cost=0.28..105.57 rows=1 width=124)
-> Seq Scan on tbl_erp_payment_ticket_settles r_2 (cost=0.00..97.25 rows=1 width=18)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{2742,2776,2737,3101,2672,2662,3112,3250,3235,3232,3247,3249,2865,2812,2783,2981,2756,2963,2708,2817}'::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: (is_payment_settle AND (status = ANY ('{2,5}'::integer[])))