QUERY PLAN
GroupAggregate (cost=70.64..573.51 rows=1 width=515)
Group Key: p.id
-> Nested Loop Left Join (cost=70.64..573.42 rows=1 width=547)
Join Filter: (p.id = t_4.project_id)
-> Nested Loop Left Join (cost=69.45..570.26 rows=1 width=515)
Join Filter: (p.id = sc_1.from_project)
-> Nested Loop Left Join (cost=69.45..500.96 rows=1 width=483)
Join Filter: (p.id = sc.from_project)
-> Nested Loop Left Join (cost=1.55..12.78 rows=1 width=451)
Join Filter: (p.id = t_1.project_id)
-> Nested Loop Left Join (cost=1.55..11.51 rows=1 width=419)
Join Filter: (p.id = t.project_id)
-> Index Scan using tbl_projects_pkey on tbl_projects p (cost=0.28..8.30 rows=1 width=355)
Index Cond: (id = 3910)
-> GroupAggregate (cost=1.27..3.19 rows=1 width=68)
Group Key: t.project_id
-> Hash Right Join (cost=1.27..3.15 rows=4 width=13)
Hash Cond: (eipss.erp_sales_outbound_id = t.id)
-> Seq Scan on tbl_erp_inventory_product_spents eipss (cost=0.00..1.68 rows=68 width=13)
-> Hash (cost=1.25..1.25 rows=1 width=8)
-> Seq Scan on tbl_erp_sales_outbounds t (cost=0.00..1.25 rows=1 width=8)
Filter: ((project_id IS NOT NULL) AND (status = 2) AND (project_id = 3910))
-> GroupAggregate (cost=0.00..1.24 rows=1 width=36)
Group Key: t_1.project_id
-> Seq Scan on tbl_erp_cost_tickets t_1 (cost=0.00..1.23 rows=1 width=9)
Filter: ((project_id IS NOT NULL) AND (status = 2) AND (project_id = 3910))
-> GroupAggregate (cost=67.90..488.16 rows=1 width=36)
Group Key: sc.from_project
-> Hash Join (cost=67.90..488.13 rows=4 width=9)
Hash Cond: (t_2.sales_contract_id = sc.id)
-> Seq Scan on tbl_erp_cash_cost_tickets t_2 (cost=0.00..400.68 rows=7445 width=9)
Filter: (status = 2)
-> Hash (cost=67.89..67.89 rows=1 width=8)
-> Seq Scan on tbl_sales_contracts sc (cost=0.00..67.89 rows=1 width=8)
Filter: ((from_project IS NOT NULL) AND (from_project = 3910))
-> GroupAggregate (cost=0.00..69.28 rows=1 width=36)
Group Key: sc_1.from_project
-> Nested Loop (cost=0.00..69.26 rows=1 width=9)
Join Filter: (t_3.sales_contract_id = sc_1.id)
-> Seq Scan on tbl_sales_contracts sc_1 (cost=0.00..67.89 rows=1 width=8)
Filter: ((from_project IS NOT NULL) AND (from_project = 3910))
-> Seq Scan on tbl_erp_cost_convert_tickets t_3 (cost=0.00..1.19 rows=15 width=9)
Filter: (status = 2)
-> GroupAggregate (cost=1.19..3.13 rows=1 width=36)
Group Key: t_4.project_id
-> Hash Right Join (cost=1.19..3.07 rows=6 width=13)
Hash Cond: (eipss_1.erp_sales_gift_id = t_4.id)
-> Seq Scan on tbl_erp_inventory_product_spents eipss_1 (cost=0.00..1.68 rows=68 width=13)
-> Hash (cost=1.18..1.18 rows=1 width=8)
-> Seq Scan on tbl_erp_sales_gifts t_4 (cost=0.00..1.18 rows=1 width=8)
Filter: ((project_id IS NOT NULL) AND (status = 2) AND (project_id = 3910))