pingcap / pingcap/tidb

Build join instead of apply for non-correlated subquery

Open
#37,522 0 comments 1 reaction 1 assignee Claimed by @hawkingrei View on GitHub
sig/planner type/enhancement
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.