| Aggregate (cost=131.00..131.01 rows=1 width=32) |
| -> Append (cost=29.84..130.99 rows=2 width=32) |
| -> Aggregate (cost=29.84..29.85 rows=1 width=32) |
| -> Nested Loop Left Join (cost=14.38..29.84 rows=2 width=32) |
| Filter: ((NOT (hashed SubPlan 1)) OR (t.sales_contract_id IS NULL)) |
| -> Hash Join (cost=1.20..3.96 rows=2 width=36) |
| Hash Cond: (t.id = am.erp_other_income_ticket_id) |
| -> Seq Scan on tbl_erp_other_income_tickets t (cost=0.00..2.70 rows=11 width=8) |
| Filter: ((created_at >= '2026-01-01 00:00:00+08'::timestamp with time zone) AND (created_at <= '2026-12-31 23:59:59+08'::timestamp with time zone) AND (status = 2)) |
| -> Hash (cost=1.09..1.09 rows=9 width=36) |
| -> Seq Scan on tbl_erp_other_income_ticket_handlers am (cost=0.00..1.09 rows=9 width=36) |
| -> Index Scan using tbl_sales_contracts_pkey on tbl_sales_contracts sc (cost=0.28..6.48 rows=1 width=8) |
| Index Cond: (id = t.sales_contract_id) |
| 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=101.11..101.12 rows=1 width=32) |
| -> Nested Loop (cost=13.19..101.10 rows=1 width=11) |
| Join Filter: (pd.id = am_1.erp_profit_distribute_id) |
| -> Nested Loop (cost=13.19..99.92 rows=1 width=10) |
| Join Filter: (pd.project_id = sc_1.from_project) |
| -> Hash Join (cost=12.91..25.83 rows=1 width=12) |
| Hash Cond: (pd.project_id = t_2.project_id) |
| -> Seq Scan on tbl_erp_profit_distributes pd (cost=0.00..12.30 rows=230 width=8) |
| -> 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)) |
| -> Nested Loop (cost=0.28..73.95 rows=11 width=10) |
| -> Seq Scan on tbl_erp_other_income_tickets t_1 (cost=0.00..2.70 rows=11 width=10) |
| Filter: ((created_at >= '2026-01-01 00:00:00+08'::timestamp with time zone) AND (created_at <= '2026-12-31 23:59:59+08'::timestamp with time zone) AND (status = 2)) |
| -> Index Scan using tbl_sales_contracts_pkey on tbl_sales_contracts sc_1 (cost=0.28..6.48 rows=1 width=8) |
| Index Cond: (id = t_1.sales_contract_id) |
| -> Seq Scan on tbl_erp_profit_distribute_pcts am_1 (cost=0.00..1.08 rows=8 width=9) |