| Aggregate (cost=1597.25..1597.26 rows=1 width=8) |
| -> Sort (cost=1596.46..1596.59 rows=53 width=870) |
| Sort Key: p.erp_j_profit_amount, p.updated_at DESC |
| -> Subquery Scan on p (cost=1590.70..1594.94 rows=53 width=870) |
| -> GroupAggregate (cost=1590.70..1594.41 rows=53 width=842) |
| Group Key: p_1.id, pd.user_id, pd.pct |
| -> Sort (cost=1590.70..1590.83 rows=53 width=280) |
| Sort Key: p_1.id, pd.user_id, pd.pct |
| -> Hash Left Join (cost=1465.35..1589.18 rows=53 width=280) |
| Hash Cond: (p_1.id = esgs.project_id) |
| -> Hash Left Join (cost=1441.59..1565.28 rows=53 width=248) |
| Hash Cond: (p_1.id = eccrta.project_id) |
| -> Hash Left Join (cost=1432.10..1555.66 rows=53 width=216) |
| Hash Cond: (p_1.id = ecctcpc.project_id) |
| -> Hash Left Join (cost=845.69..969.10 rows=53 width=184) |
| Hash Cond: (p_1.id = ecctasc.project_id) |
| -> Hash Left Join (cost=254.01..377.28 rows=53 width=152) |
| Hash Cond: (p_1.id = ecta.project_id) |
| -> Hash Left Join (cost=248.30..371.44 rows=53 width=120) |
| Hash Cond: (p_1.id = o.project_id) |
| -> Hash Left Join (cost=214.76..337.76 rows=53 width=56) |
| Hash Cond: (p_1.id = pd.project_id) |
| -> Hash Right Join (cost=200.65..323.44 rows=53 width=20) |
| Hash Cond: (sc.from_project = p_1.id) |
| -> Seq Scan on tbl_sales_contracts sc (cost=0.00..118.25 rows=1725 width=4) |
| -> Hash (cost=199.99..199.99 rows=53 width=20) |
| -> Seq Scan on tbl_projects p_1 (cost=0.00..199.99 rows=53 width=20) |
| Filter: ((bargain_date >= '2026-01-01'::date) AND (bargain_date <= '2026-12-31'::date) AND (project_status = 3)) |
| -> Hash (cost=14.10..14.10 rows=1 width=40) |
| -> Subquery Scan on pd (cost=14.06..14.10 rows=1 width=40) |
| -> GroupAggregate (cost=14.06..14.09 rows=1 width=40) |
| Group Key: t.project_id, r.user_id |
| -> Sort (cost=14.06..14.07 rows=1 width=13) |
| Sort Key: t.project_id, r.user_id |
| -> Nested Loop Left Join (cost=0.00..14.05 rows=1 width=13) |
| Join Filter: (t.id = r.erp_profit_distribute_id) |
| -> Seq Scan on tbl_erp_profit_distributes t (cost=0.00..12.88 rows=1 width=8) |
| Filter: ((project_id IS NOT NULL) AND (status = 2)) |
| -> Seq Scan on tbl_erp_profit_distribute_pcts r (cost=0.00..1.08 rows=8 width=13) |
| -> Hash (cost=31.88..31.88 rows=133 width=68) |
| -> Subquery Scan on o (cost=28.55..31.88 rows=133 width=68) |
| -> HashAggregate (cost=28.55..30.55 rows=133 width=68) |
| Group Key: t_1.project_id |
| -> Hash Right Join (cost=10.69..24.67 rows=518 width=13) |
| Hash Cond: (eipss.erp_sales_outbound_id = t_1.id) |
| -> Seq Scan on tbl_erp_inventory_product_spents eipss (cost=0.00..12.51 rows=551 width=13) |
| -> Hash (cost=8.90..8.90 rows=143 width=8) |
| -> Seq Scan on tbl_erp_sales_outbounds t_1 (cost=0.00..8.90 rows=143 width=8) |
| Filter: ((project_id IS NOT NULL) AND (status = 2)) |
| -> Hash (cost=5.20..5.20 rows=41 width=36) |
| -> Subquery Scan on ecta (cost=4.28..5.20 rows=41 width=36) |
| -> HashAggregate (cost=4.28..4.79 rows=41 width=36) |
| Group Key: t_2.project_id |
| -> Seq Scan on tbl_erp_cost_tickets t_2 (cost=0.00..4.03 rows=50 width=9) |
| Filter: ((project_id IS NOT NULL) AND (status = 2)) |
| -> Hash (cost=591.16..591.16 rows=42 width=36) |
| -> Subquery Scan on ecctasc (cost=589.90..591.16 rows=42 width=36) |
| -> GroupAggregate (cost=589.90..590.74 rows=42 width=36) |
| Group Key: sc_1.from_project |
| -> Sort (cost=589.90..590.00 rows=42 width=9) |
| Sort Key: sc_1.from_project |
| -> Nested Loop (cost=550.88..588.76 rows=42 width=9) |
| -> Hash Right Join (cost=550.60..574.11 rows=42 width=9) |
| Hash Cond: (cpc.erp_cash_cost_ticket_id = t_3.id) |
| Filter: (cpc.id IS NULL) |
| -> Seq Scan on tbl_erp_cash_cost_ticket_client_project_costs cpc (cost=0.00..20.70 rows=1070 width=8) |
| -> Hash (cost=444.86..444.86 rows=8459 width=13) |
| -> Seq Scan on tbl_erp_cash_cost_tickets t_3 (cost=0.00..444.86 rows=8459 width=13) |
| Filter: (status = 2) |
| -> Index Scan using tbl_sales_contracts_pkey on tbl_sales_contracts sc_1 (cost=0.28..0.35 rows=1 width=8) |
| Index Cond: (id = t_3.sales_contract_id) |
| Filter: (from_project IS NOT NULL) |
| -> Hash (cost=583.92..583.92 rows=200 width=36) |
| -> Subquery Scan on ecctcpc (cost=579.42..583.92 rows=200 width=36) |
| -> HashAggregate (cost=579.42..581.92 rows=200 width=36) |
| Group Key: cpc_1.project_id |
| -> Hash Join (cost=550.60..574.10 rows=1064 width=36) |
| Hash Cond: (cpc_1.erp_cash_cost_ticket_id = t_4.id) |
| -> Seq Scan on tbl_erp_cash_cost_ticket_client_project_costs cpc_1 (cost=0.00..20.70 rows=1065 width=40) |
| Filter: (project_id IS NOT NULL) |
| -> Hash (cost=444.86..444.86 rows=8459 width=4) |
| -> Seq Scan on tbl_erp_cash_cost_tickets t_4 (cost=0.00..444.86 rows=8459 width=4) |
| Filter: (status = 2) |
| -> Hash (cost=9.47..9.47 rows=1 width=36) |
| -> Subquery Scan on eccrta (cost=9.44..9.47 rows=1 width=36) |
| -> GroupAggregate (cost=9.44..9.46 rows=1 width=36) |
| Group Key: sc_2.from_project |
| -> Sort (cost=9.44..9.44 rows=1 width=36) |
| Sort Key: sc_2.from_project |
| -> Nested Loop (cost=0.28..9.43 rows=1 width=36) |
| -> Seq Scan on tbl_erp_cost_convert_tickets t_5 (cost=0.00..1.12 rows=1 width=36) |
| Filter: (status = 2) |
| -> Index Scan using tbl_sales_contracts_pkey on tbl_sales_contracts sc_2 (cost=0.28..8.29 rows=1 width=8) |
| Index Cond: (id = t_5.sales_contract_id) |
| Filter: (from_project IS NOT NULL) |
| -> Hash (cost=23.55..23.55 rows=17 width=36) |
| -> Subquery Scan on esgs (cost=23.16..23.55 rows=17 width=36) |
| -> HashAggregate (cost=23.16..23.38 rows=17 width=36) |
| Group Key: t_6.project_id |
| -> Hash Right Join (cost=7.99..21.95 rows=161 width=13) |
| Hash Cond: (eipss_1.erp_sales_gift_id = t_6.id) |
| -> Seq Scan on tbl_erp_inventory_product_spents eipss_1 (cost=0.00..12.51 rows=551 width=13) |
| -> Hash (cost=7.54..7.54 rows=36 width=8) |
| -> Seq Scan on tbl_erp_sales_gifts t_6 (cost=0.00..7.54 rows=36 width=8) |
| Filter: ((project_id IS NOT NULL) AND (status = 2)) |