| Aggregate (cost=90.63..90.64 rows=1 width=64) |
| -> Append (cost=38.57..90.62 rows=2 width=64) |
| -> Aggregate (cost=38.57..38.58 rows=1 width=64) |
| -> Hash Right Join (cost=23.61..37.59 rows=196 width=9) |
| Hash Cond: (eipss.erp_sales_outbound_id = t.id) |
| -> Seq Scan on tbl_erp_inventory_product_spents eipss (cost=0.00..12.51 rows=551 width=13) |
| -> Hash (cost=22.93..22.93 rows=54 width=4) |
| -> Seq Scan on tbl_erp_sales_outbounds t (cost=12.89..22.93 rows=54 width=4) |
| Filter: (((NOT (hashed SubPlan 1)) OR (project_id IS NULL)) AND (created_at >= '2025-08-05 00:00:00+08'::timestamp with time zone) AND (created_at <= '2025-12-31 23:59:59+08'::timestamp with time zone) AND (status = 2)) |
| SubPlan 1 |
| -> Group (cost=12.88..12.89 rows=1 width=4) |
| Group Key: t_3.project_id |
| -> Sort (cost=12.88..12.89 rows=1 width=4) |
| Sort Key: t_3.project_id |
| -> Seq Scan on tbl_erp_profit_distributes t_3 (cost=0.00..12.88 rows=1 width=4) |
| Filter: ((project_id IS NOT NULL) AND (status = 2)) |
| -> Aggregate (cost=52.01..52.02 rows=1 width=64) |
| -> Nested Loop (cost=36.06..51.99 rows=1 width=14) |
| Join Filter: (pd.id = am.erp_profit_distribute_id) |
| -> Seq Scan on tbl_erp_profit_distribute_pcts am (cost=0.00..1.08 rows=8 width=9) |
| -> Materialize (cost=36.06..50.67 rows=2 width=13) |
| -> Hash Right Join (cost=36.06..50.66 rows=2 width=13) |
| Hash Cond: (eipss_1.erp_sales_outbound_id = t_1.id) |
| -> Seq Scan on tbl_erp_inventory_product_spents eipss_1 (cost=0.00..12.51 rows=551 width=13) |
| -> Hash (cost=36.05..36.05 rows=1 width=8) |
| -> Hash Join (cost=22.88..36.05 rows=1 width=8) |
| Hash Cond: (pd.project_id = t_1.project_id) |
| -> Seq Scan on tbl_erp_profit_distributes pd (cost=0.00..12.30 rows=230 width=8) |
| -> Hash (cost=22.87..22.87 rows=1 width=12) |
| -> Hash Join (cost=12.91..22.87 rows=1 width=12) |
| Hash Cond: (t_1.project_id = t_2.project_id) |
| -> Seq Scan on tbl_erp_sales_outbounds t_1 (cost=0.00..9.66 rows=107 width=8) |
| Filter: ((created_at >= '2025-08-05 00:00:00+08'::timestamp with time zone) AND (created_at <= '2025-12-31 23:59:59+08'::timestamp with time zone) AND (status = 2)) |
| -> Hash (cost=12.90..12.90 rows=1 width=4) |
| -> Group (cost=12.88..12.89 rows=1 width=4) |
| Group Key: t_2.project_id |
| -> Sort (cost=12.88..12.89 rows=1 width=4) |
| Sort Key: t_2.project_id |
| -> Seq Scan on tbl_erp_profit_distributes t_2 (cost=0.00..12.88 rows=1 width=4) |
| Filter: ((project_id IS NOT NULL) AND (status = 2)) |