| Aggregate (cost=46.85..46.86 rows=1 width=64) |
| -> Append (cost=22.35..46.83 rows=2 width=64) |
| -> Aggregate (cost=22.35..22.36 rows=1 width=64) |
| -> Hash Right Join (cost=8.17..22.32 rows=4 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=8.15..8.15 rows=1 width=4) |
| -> Seq Scan on tbl_erp_sales_outbounds t (cost=1.07..8.15 rows=1 width=4) |
| Filter: (((NOT (hashed SubPlan 1)) OR (project_id IS NULL)) AND (created_at >= '2025-03-01 00:00:00+08'::timestamp with time zone) AND (created_at <= '2025-03-31 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.45..24.46 rows=1 width=64) |
| -> Nested Loop (cost=8.86..24.40 rows=3 width=15) |
| Join Filter: (pd.project_id = t_1.project_id) |
| -> Nested Loop (cost=7.77..22.08 rows=1 width=18) |
| Join Filter: (t_1.project_id = t_2.project_id) |
| -> 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)) |
| -> Materialize (cost=6.71..20.88 rows=4 width=14) |
| -> Hash Right Join (cost=6.71..20.86 rows=4 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=6.70..6.70 rows=1 width=8) |
| -> Seq Scan on tbl_erp_sales_outbounds t_1 (cost=0.00..6.70 rows=1 width=8) |
| Filter: ((created_at >= '2025-03-01 00:00:00+08'::timestamp with time zone) AND (created_at <= '2025-03-31 23:59:59+08'::timestamp with time zone) AND (status = 2)) |
| -> Hash Join (cost=1.09..2.21 rows=8 width=9) |
| Hash Cond: (am.erp_profit_distribute_id = pd.id) |
| -> Seq Scan on tbl_erp_profit_distribute_pcts am (cost=0.00..1.08 rows=8 width=9) |
| -> Hash (cost=1.04..1.04 rows=4 width=8) |
| -> Seq Scan on tbl_erp_profit_distributes pd (cost=0.00..1.04 rows=4 width=8) |