QUERY PLAN
Sort (cost=499.11..499.27 rows=62 width=133)
Sort Key: "*SELECT* 1".id DESC
-> Result (cost=94.76..497.26 rows=62 width=133)
-> Append (cost=94.76..496.64 rows=62 width=101)
-> Subquery Scan on "*SELECT* 1" (cost=94.76..192.49 rows=21 width=84)
-> Hash Join (cost=94.76..192.28 rows=21 width=88)
Hash Cond: (r.erp_payment_ticket_id = t.id)
-> Seq Scan on tbl_erp_payment_ticket_settles r (cost=0.00..97.25 rows=21 width=18)
Filter: (purchase_contract_id = ANY ('{4240,4145,4136,4122,4103,4098,4056,4000,3987,3982,3969,3936,3917,3903,3902,3901,3863,3804,3769,4118}'::integer[]))
-> Hash (cost=67.60..67.60 rows=2173 width=38)
-> Seq Scan on tbl_erp_payment_tickets t (cost=0.00..67.60 rows=2173 width=38)
Filter: (is_payment_settle AND (status = ANY ('{2,5}'::integer[])))
-> Subquery Scan on "*SELECT* 2" (cost=1.14..2.42 rows=1 width=120)
-> Hash Join (cost=1.14..2.41 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=48)
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 ('{4240,4145,4136,4122,4103,4098,4056,4000,3987,3982,3969,3936,3917,3903,3902,3901,3863,3804,3769,4118}'::integer[]))
-> Subquery Scan on "*SELECT* 3" (cost=0.28..144.40 rows=20 width=118)
-> Nested Loop (cost=0.28..144.20 rows=20 width=122)
-> 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 ('{4240,4145,4136,4122,4103,4098,4056,4000,3987,3982,3969,3936,3917,3903,3902,3901,3863,3804,3769,4118}'::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=46)
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.34 rows=20 width=100)
-> Hash Join (cost=86.95..157.14 rows=20 width=104)
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=28)
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 ('{4240,4145,4136,4122,4103,4098,4056,4000,3987,3982,3969,3936,3917,3903,3902,3901,3863,3804,3769,4118}'::integer[]))