Router planner does not detect correlated subquery join
- Dominant language
- C
- Stars
- 12.8k
- Forks
- 794
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 31
Description
This query could be answered with a single task, but becomes a multi-shard query:
```sql
explain analyze select (select count(*) from pgbench_accounts where aid = a.aid) from pgbench_accounts a where aid = 1;
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------
Custom Scan (Citus Adaptive) (cost=0.00..0.00 rows=100000 width=8) (actual time=9.536..9.539 rows=1 loops=1)
Task Count: 32
Tuple data received from nodes: 1 bytes
Tasks Shown: One of 32
-> Task
Tuple data received from node: 1 bytes
Node: host=10.192.0.12 port=5432 dbname=pguser
-> Index Only Scan using pgbench_accounts_pkey_297689 on pgbench_accounts_297689 a (cost=0.43..8.91 rows=1 width=8) (actual time=0.063..0.068 rows=1 loops=1)
Index Cond: (aid = 1)
Heap Fetches: 1
SubPlan 1
-> Aggregate (cost=4.45..4.46 rows=1 width=8) (actual time=0.014..0.017 rows=1 loops=1)
-> Index Only Scan using pgbench_accounts_pkey_297689 on pgbench_accounts_297689 pgbench_accounts (cost=0.43..4.45 rows=1 width=0) (actual time=0.005..0.
007 rows=1 loops=1)
Index Cond: (aid = a.aid)
Heap Fetches: 1
Planning Time: 0.113 ms
Execution Time: 0.107 ms
Planning Time: 1.789 ms
Execution Time: 9.559 ms
(19 rows)
```
Contributor guide
Assessment
This issue has not been assessed yet.