| Aggregate (cost=48.77..48.78 rows=1 width=64) |
| -> Append (cost=24.35..48.76 rows=2 width=64) |
| -> Aggregate (cost=24.35..24.36 rows=1 width=64) |
| -> Hash Right Join (cost=10.04..24.20 rows=29 width=10) |
| Hash Cond: (eipss.erp_sales_outbound_id = t.id) |
| -> Seq Scan on tbl_erp_inventory_product_spents eipss (cost=0.00..12.65 rows=565 width=14) |
| -> Hash (cost=9.91..9.91 rows=10 width=4) |
| -> Seq Scan on tbl_erp_sales_outbounds t (cost=1.07..9.91 rows=10 width=4) |
| Filter: (((NOT (hashed SubPlan 1)) OR (project_id IS NULL)) AND (created_at >= '2025-09-01 00:00:00+08'::timestamp with time zone) AND (created_at <= '2025-09-30 23:59:59+08'::timestamp with time zone) AND (status = 2)) |
| SubPlan 1 |
| -> Group (cost=1.06..1.07 rows=2 width=4) |
| Group Key: t_3.project_id |
| -> Sort (cost=1.06..1.06 rows=2 width=4) |
| Sort Key: t_3.project_id |
| -> Seq Scan on tbl_erp_profit_distributes t_3 (cost=0.00..1.05 rows=2 width=4) |
| Filter: ((project_id IS NOT NULL) AND (status = 2)) |
| -> Aggregate (cost=24.37..24.38 rows=1 width=64) |
| -> Merge Join (cost=11.04..24.34 rows=2 width=15) |
| Merge Cond: (pd.id = am.erp_profit_distribute_id) |
| -> Nested Loop (cost=9.84..36.27 rows=2 width=14) |
| Join Filter: (t_1.project_id = pd.project_id) |
| -> Index Scan using tbl_erp_profit_distributes_pkey on tbl_erp_profit_distributes pd (cost=0.13..12.19 rows=4 width=8) |
| -> Materialize (cost=9.71..24.02 rows=1 width=18) |
| -> Hash Join (cost=9.71..24.01 rows=1 width=18) |
| Hash Cond: (t_1.project_id = t_2.project_id) |
| -> Hash Right Join (cost=8.60..22.75 rows=56 width=14) |
| 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.65 rows=565 width=14) |
| -> Hash (cost=8.36..8.36 rows=19 width=8) |
| -> Seq Scan on tbl_erp_sales_outbounds t_1 (cost=0.00..8.36 rows=19 width=8) |
| Filter: ((created_at >= '2025-09-01 00:00:00+08'::timestamp with time zone) AND (created_at <= '2025-09-30 23:59:59+08'::timestamp with time zone) AND (status = 2)) |
| -> Hash (cost=1.09..1.09 rows=2 width=4) |
| -> Group (cost=1.06..1.07 rows=2 width=4) |
| Group Key: t_2.project_id |
| -> Sort (cost=1.06..1.06 rows=2 width=4) |
| Sort Key: t_2.project_id |
| -> Seq Scan on tbl_erp_profit_distributes t_2 (cost=0.00..1.05 rows=2 width=4) |
| Filter: ((project_id IS NOT NULL) AND (status = 2)) |
| -> Sort (cost=1.20..1.22 rows=8 width=9) |
| Sort Key: am.erp_profit_distribute_id |
| -> Seq Scan on tbl_erp_profit_distribute_pcts am (cost=0.00..1.08 rows=8 width=9) |