QUERY PLAN
Sort (cost=354.23..354.35 rows=47 width=130)
Sort Key: "*SELECT* 1".id DESC
-> Result (cost=88.25..352.93 rows=47 width=130)
-> Append (cost=88.25..352.46 rows=47 width=99)
-> Subquery Scan on "*SELECT* 1" (cost=88.25..157.20 rows=21 width=83)
-> Hash Join (cost=88.25..156.99 rows=21 width=87)
Hash Cond: (t.id = r.erp_payment_ticket_id)
-> Seq Scan on tbl_erp_payment_tickets t (cost=0.00..60.42 rows=2105 width=37)
Filter: (is_payment_settle AND (status = ANY ('{2,5}'::integer[])))
-> Hash (cost=87.99..87.99 rows=21 width=18)
-> Seq Scan on tbl_erp_payment_ticket_settles r (cost=0.00..87.99 rows=21 width=18)
Filter: (purchase_contract_id = ANY ('{4141,4133,4122,4103,4098,4056,4000,3987,3982,3969,3936,3917,3903,3902,3901,3863,3804,3769,4118,3756}'::integer[]))
-> Subquery Scan on "*SELECT* 2" (cost=0.00..2.14 rows=1 width=120)
-> Nested Loop (cost=0.00..2.13 rows=1 width=124)
Join Filter: (r_1.erp_other_income_ticket_id = t_1.id)
-> Seq Scan on tbl_erp_other_income_ticket_purchase_contract_settles r_1 (cost=0.00..1.03 rows=1 width=44)
Filter: (purchase_contract_id = ANY ('{4141,4133,4122,4103,4098,4056,4000,3987,3982,3969,3936,3917,3903,3902,3901,3863,3804,3769,4118,3756}'::integer[]))
-> Seq Scan on tbl_erp_other_income_tickets t_1 (cost=0.00..1.06 rows=2 width=48)
Filter: (status = ANY ('{2,5}'::integer[]))
-> Subquery Scan on "*SELECT* 3" (cost=0.28..42.79 rows=5 width=118)
-> Nested Loop (cost=0.28..42.74 rows=5 width=122)
-> Seq Scan on tbl_erp_cash_cost_ticket_purchase_contract_settles r_2 (cost=0.00..1.18 rows=5 width=44)
Filter: (purchase_contract_id = ANY ('{4141,4133,4122,4103,4098,4056,4000,3987,3982,3969,3936,3917,3903,3902,3901,3863,3804,3769,4118,3756}'::integer[]))
-> Index Scan using tbl_erp_cash_cost_tickets_pkey on tbl_erp_cash_cost_tickets t_2 (cost=0.28..8.30 rows=1 width=46)
Index Cond: (id = r_2.erp_cash_cost_ticket_id)
Filter: (status = ANY ('{2,5}'::integer[]))
-> Subquery Scan on "*SELECT* 4" (cost=83.88..150.32 rows=20 width=109)
-> Hash Join (cost=83.88..150.12 rows=20 width=113)
Hash Cond: (t_3.id = r_3.erp_collect_ticket_id)
-> Seq Scan on tbl_erp_collect_tickets t_3 (cost=0.00..58.24 rows=2015 width=37)
Filter: (status = ANY ('{2,5}'::integer[]))
-> Hash (cost=83.63..83.63 rows=20 width=18)
-> Seq Scan on tbl_erp_collect_ticket_settles r_3 (cost=0.00..83.63 rows=20 width=18)
Filter: (purchase_contract_id = ANY ('{4141,4133,4122,4103,4098,4056,4000,3987,3982,3969,3936,3917,3903,3902,3901,3863,3804,3769,4118,3756}'::integer[]))