QUERY PLAN
Sort (cost=498.89..499.04 rows=61 width=91)
Sort Key: "*SELECT* 1".id DESC
-> Result (cost=94.76..497.08 rows=61 width=91)
-> Append (cost=94.76..496.47 rows=61 width=59)
-> Subquery Scan on "*SELECT* 1" (cost=94.76..192.41 rows=20 width=42)
-> Hash Join (cost=94.76..192.22 rows=20 width=98)
Hash Cond: (r.erp_payment_ticket_id = t.id)
-> Seq Scan on tbl_erp_payment_ticket_settles r (cost=0.00..97.25 rows=20 width=18)
Filter: (purchase_contract_id = ANY ('{1182,2204,755,3640,2218,517,1985,2605,2834,1016,247,191,1063,1122,1331,1838,432,2383,1825,692}'::integer[]))
-> Hash (cost=67.60..67.60 rows=2173 width=4)
-> Seq Scan on tbl_erp_payment_tickets t (cost=0.00..67.60 rows=2173 width=4)
Filter: (is_payment_settle AND (status = ANY ('{2,5}'::integer[])))
-> Subquery Scan on "*SELECT* 2" (cost=1.14..2.41 rows=1 width=68)
-> Hash Join (cost=1.14..2.40 rows=1 width=124)
Hash Cond: (t_1.id = r_1.erp_other_income_ticket_id)
-> Seq Scan on tbl_erp_other_income_tickets t_1 (cost=0.00..1.24 rows=2 width=4)
Filter: (status = ANY ('{2,5}'::integer[]))
-> Hash (cost=1.10..1.10 rows=3 width=44)
-> Seq Scan on tbl_erp_other_income_ticket_purchase_contract_settles r_1 (cost=0.00..1.10 rows=3 width=44)
Filter: (purchase_contract_id = ANY ('{1182,2204,755,3640,2218,517,1985,2605,2834,1016,247,191,1063,1122,1331,1838,432,2383,1825,692}'::integer[]))
-> Subquery Scan on "*SELECT* 3" (cost=0.28..144.35 rows=20 width=68)
-> Nested Loop (cost=0.28..144.15 rows=20 width=124)
-> Seq Scan on tbl_erp_cash_cost_ticket_purchase_contract_settles r_2 (cost=0.00..1.95 rows=20 width=44)
Filter: (purchase_contract_id = ANY ('{1182,2204,755,3640,2218,517,1985,2605,2834,1016,247,191,1063,1122,1331,1838,432,2383,1825,692}'::integer[]))
-> Index Scan using tbl_erp_cash_cost_tickets_pkey on tbl_erp_cash_cost_tickets t_2 (cost=0.28..7.10 rows=1 width=4)
Index Cond: (id = r_2.erp_cash_cost_ticket_id)
Filter: (is_payment_settle AND (status = ANY ('{2,5}'::integer[])))
-> Subquery Scan on "*SELECT* 4" (cost=86.95..157.29 rows=20 width=68)
-> Hash Join (cost=86.95..157.09 rows=20 width=124)
Hash Cond: (t_3.id = r_3.erp_collect_ticket_id)
-> Seq Scan on tbl_erp_collect_tickets t_3 (cost=0.00..61.74 rows=2136 width=4)
Filter: (status = ANY ('{2,5}'::integer[]))
-> Hash (cost=86.70..86.70 rows=20 width=18)
-> Seq Scan on tbl_erp_collect_ticket_settles r_3 (cost=0.00..86.70 rows=20 width=18)
Filter: (purchase_contract_id = ANY ('{1182,2204,755,3640,2218,517,1985,2605,2834,1016,247,191,1063,1122,1331,1838,432,2383,1825,692}'::integer[]))