Unique (cost=905.32..905.39 rows=1 width=541) |
-> Sort (cost=905.32..905.32 rows=1 width=541) |
Sort Key: s.name, s.abbr, s.pinyin_shortcut, s.main_products, s.company_nature, s.website, s.established_at, s.capital, s.corp_rep, s.reg_address, s.telephone, s.fax, s.description, s.main_contact, s.created_by, s.created_at, s.updated_at, s.working_address, s.capital_currency, s.payment_cycle, s.account_number, (sum((sum(pc.amount)))), (sum((sum(CASE WHEN (pcp.collected IS NOT NULL) THEN pcp.collected ELSE '0'::numeric END)))), ((sum((sum(pc.amount))) - sum((sum(CASE WHEN (pcp.collected IS NOT NULL) THEN pcp.collected ELSE '0'::numeric END))))), (sum((sum(CASE WHEN ((sum(tbl_purchase_contract_invoices.amount)) IS NOT NULL) THEN (sum(tbl_purchase_contract_invoices.amount)) ELSE '0'::numeric END)))), ((sum((sum(pc.amount))) - sum((sum(CASE WHEN ((sum(tbl_purchase_contract_invoices.amount)) IS NOT NULL) THEN (sum(tbl_purchase_contract_invoices.amount)) ELSE '0'::numeric END))))) |
-> GroupAggregate (cost=848.42..905.31 rows=1 width=541) |
Group Key: s.id |
-> Nested Loop Left Join (cost=848.42..905.24 rows=2 width=477) |
Join Filter: (pc.supplier_id = s.id) |
-> Index Scan using tbl_suppliers_pkey on tbl_suppliers s (cost=0.28..8.29 rows=1 width=381) |
Index Cond: (id = 431) |
-> GroupAggregate (cost=848.14..896.91 rows=2 width=100) |
Group Key: pc.supplier_id |
-> Hash Left Join (cost=848.14..896.85 rows=2 width=74) |
Hash Cond: (pc.id = pcp.contract_id) |
-> Hash Right Join (cost=126.44..175.15 rows=2 width=46) |
Hash Cond: (tbl_purchase_contract_invoices.contract_id = pc.id) |
-> HashAggregate (cost=61.26..85.48 rows=1938 width=36) |
Group Key: tbl_purchase_contract_invoices.contract_id |
-> Seq Scan on tbl_purchase_contract_invoices (cost=0.00..50.17 rows=2217 width=10) |
-> Hash (cost=65.16..65.16 rows=2 width=14) |
-> Seq Scan on tbl_purchase_contracts pc (cost=0.00..65.16 rows=2 width=14) |
Filter: ((NOT is_chargeback) AND (NOT is_draft) AND (NOT is_refuse) AND (supplier_id = 431)) |
-> Hash (cost=719.20..719.20 rows=200 width=36) |
-> Subquery Scan on pcp (cost=714.70..719.20 rows=200 width=36) |
-> HashAggregate (cost=714.70..717.20 rows=200 width=36) |
Group Key: "*SELECT* 1".contract_id |
-> Append (cost=87.23..690.46 rows=4847 width=25) |
-> Subquery Scan on "*SELECT* 1" (cost=87.23..147.99 rows=2066 width=10) |
-> Hash Join (cost=87.23..127.33 rows=2066 width=98) |
Hash Cond: (r.erp_payment_ticket_id = t.id) |
-> Seq Scan on tbl_erp_payment_ticket_settles r (cost=0.00..34.66 rows=2066 width=14) |
-> Hash (cost=61.41..61.41 rows=2066 width=4) |
-> Seq Scan on tbl_erp_payment_tickets t (cost=0.00..61.41 rows=2066 width=4) |
Filter: (status = ANY ('{2,5,1}'::integer[])) |
-> Subquery Scan on "*SELECT* 2" (cost=12.79..32.80 rows=12 width=36) |
-> Hash Join (cost=12.79..32.68 rows=12 width=124) |
Hash Cond: (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..17.80 rows=780 width=40) |
-> Hash (cost=12.75..12.75 rows=3 width=4) |
-> Seq Scan on tbl_erp_other_income_tickets t_1 (cost=0.00..12.75 rows=3 width=4) |
Filter: (status = ANY ('{2,5,1}'::integer[])) |
-> Subquery Scan on "*SELECT* 3" (cost=334.84..362.48 rows=780 width=36) |
-> Hash Join (cost=334.84..354.68 rows=780 width=124) |
Hash Cond: (r_2.erp_cash_cost_ticket_id = t_2.id) |
-> Seq Scan on tbl_erp_cash_cost_ticket_purchase_contract_settles r_2 (cost=0.00..17.80 rows=780 width=40) |
-> Hash (cost=243.49..243.49 rows=7308 width=4) |
-> Seq Scan on tbl_erp_cash_cost_tickets t_2 (cost=0.00..243.49 rows=7308 width=4) |
Filter: (status = ANY ('{2,5,1}'::integer[])) |
-> Subquery Scan on "*SELECT* 4" (cost=84.21..147.20 rows=1989 width=36) |
-> Hash Join (cost=84.21..127.31 rows=1989 width=124) |
Hash Cond: (r_3.erp_collect_ticket_id = t_3.id) |
-> Seq Scan on tbl_erp_collect_ticket_settles r_3 (cost=0.00..32.89 rows=1989 width=14) |
-> Hash (cost=59.35..59.35 rows=1989 width=4) |
-> Seq Scan on tbl_erp_collect_tickets t_3 (cost=0.00..59.35 rows=1989 width=4) |
Filter: (status = ANY ('{2,5,1}'::integer[])) |