QUERY PLAN
Limit (cost=1768.54..1768.59 rows=20 width=591)
-> Sort (cost=1768.54..1772.51 rows=1586 width=591)
Sort Key: p.updated_at DESC
-> HashAggregate (cost=1591.53..1726.34 rows=1586 width=591)
Group Key: p.id, pd.user_id, pd.pct
-> Hash Left Join (cost=1334.28..1532.05 rows=1586 width=551)
Hash Cond: (p.id = ecctar.project_id)
-> Hash Left Join (cost=636.71..830.31 rows=1586 width=519)
Hash Cond: (p.id = ecctasc.project_id)
-> Hash Left Join (cost=41.96..231.38 rows=1586 width=487)
Hash Cond: (p.id = ecta.project_id)
-> Hash Left Join (cost=40.79..226.04 rows=1586 width=455)
Hash Cond: (p.id = o.project_id)
-> Hash Left Join (cost=37.62..218.69 rows=1586 width=391)
Hash Cond: (p.id = pd.project_id)
-> Seq Scan on tbl_projects p (cost=0.00..175.10 rows=1586 width=355)
Filter: (project_status = 3)
-> Hash (cost=37.55..37.55 rows=5 width=40)
-> Subquery Scan on pd (cost=37.39..37.55 rows=5 width=40)
-> GroupAggregate (cost=37.39..37.50 rows=5 width=40)
Group Key: t.project_id, r.user_id
-> Sort (cost=37.39..37.40 rows=5 width=40)
Sort Key: t.project_id, r.user_id
-> Hash Right Join (cost=13.01..37.33 rows=5 width=40)
Hash Cond: (r.erp_profit_distribute_id = t.id)
-> Seq Scan on tbl_erp_profit_distribute_pcts r (cost=0.00..21.30 rows=1130 width=40)
-> Hash (cost=13.00..13.00 rows=1 width=8)
-> Seq Scan on tbl_erp_profit_distributes t (cost=0.00..13.00 rows=1 width=8)
Filter: ((project_id IS NOT NULL) AND (status = 2))
-> Hash (cost=3.16..3.16 rows=1 width=68)
-> Subquery Scan on o (cost=3.14..3.16 rows=1 width=68)
-> HashAggregate (cost=3.14..3.15 rows=1 width=68)
Group Key: t_1.project_id
-> Hash Right Join (cost=1.22..3.11 rows=4 width=13)
Hash Cond: (eipss.erp_sales_outbound_id = t_1.id)
-> Seq Scan on tbl_erp_inventory_product_spents eipss (cost=0.00..1.68 rows=68 width=13)
-> Hash (cost=1.21..1.21 rows=1 width=8)
-> Seq Scan on tbl_erp_sales_outbounds t_1 (cost=0.00..1.21 rows=1 width=8)
Filter: ((project_id IS NOT NULL) AND (status = 2))
-> Hash (cost=1.15..1.15 rows=1 width=36)
-> Subquery Scan on ecta (cost=1.13..1.15 rows=1 width=36)
-> HashAggregate (cost=1.13..1.14 rows=1 width=36)
Group Key: t_2.project_id
-> Seq Scan on tbl_erp_cost_tickets t_2 (cost=0.00..1.12 rows=1 width=36)
Filter: ((project_id IS NOT NULL) AND (status = 2))
-> Hash (cost=574.95..574.95 rows=1584 width=36)
-> Subquery Scan on ecctasc (cost=539.31..574.95 rows=1584 width=36)
-> HashAggregate (cost=539.31..559.11 rows=1584 width=36)
Group Key: sc.from_project
-> Hash Join (cost=82.47..502.70 rows=7322 width=9)
Hash Cond: (t_3.sales_contract_id = sc.id)
-> Seq Scan on tbl_erp_cash_cost_tickets t_3 (cost=0.00..400.68 rows=7445 width=9)
Filter: (status = 2)
-> Hash (cost=62.36..62.36 rows=1609 width=8)
-> Seq Scan on tbl_sales_contracts sc (cost=0.00..62.36 rows=1609 width=8)
Filter: (from_project IS NOT NULL)
-> Hash (cost=688.25..688.25 rows=746 width=36)
-> Subquery Scan on ecctar (cost=671.46..688.25 rows=746 width=36)
-> HashAggregate (cost=671.46..680.79 rows=746 width=36)
Group Key: r_1.project_id
-> Hash Join (cost=238.78..659.01 rows=2491 width=9)
Hash Cond: (t_4.reimbursement_id = r_1.id)
-> Seq Scan on tbl_erp_cash_cost_tickets t_4 (cost=0.00..400.68 rows=7445 width=9)
Filter: (status = 2)
-> Hash (cost=206.99..206.99 rows=2543 width=8)
-> Seq Scan on tbl_reimbursements r_1 (cost=0.00..206.99 rows=2543 width=8)
Filter: (project_id IS NOT NULL)