Build join instead of apply for non-correlated subquery
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Enhancement
Currently, we always build `Apply` for some subqueries, even if it's not correlated. Then we rely on the decorrelation rule to convert it to a `Join`.
If we disable the decorrelation rule in some cases, there will be some unnecessary `Apply` which could be executed as `Join`.
We can check if it's really a correlated subquery when building plan. If it's not, we can build a `Join` instead.
And there is another related issue.
The `LogicalApply.CorCols` is a necessary field, but currently, it's not set when building plan, instead it's set in logical optimization. This might cause bugs if we disable some optimization rules.
We should set it when building the `LogicalApply`.
Contributor guide
Assessment
This issue has not been assessed yet.