pingcap / pingcap/tidb

use_toja can not be applied to a named query block & leading hint can not be applied to join children

Open
#56,724 0 comments 0 reactions 0 assignees View on GitHub
affects-7.5 report/customer sig/planner type/enhancement
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Enhancement

* use_toja should be able to be applied to a named query block
* when we build a join, we will set the preferred join hint, we could see when join child are already a join with merged schema(different table name inside), it couldn't pass the extract alias check
```
func (p *LogicalJoin) setPreferredJoinTypeAndOrder(hintInfo *tableHintInfo) {
if hintInfo == nil {
return
}

lhsAlias := extractTableAlias(p.children[0], p.blockOffset)
rhsAlias := extractTableAlias(p.children[1], p.blockOffset)

func extractTableAlias(p Plan, parentOffset int) *hintTableInfo {
if len(p.OutputNames()) > 0 && p.OutputNames()[0].TblName.L != "" {
firstName := p.OutputNames()[0]
for _, name := range p.OutputNames() {
if name.TblName.L != firstName.TblName.L ||
(name.DBName.L != "" && firstName.DBName.L != "" && name.DBName.L != firstName.DBName.L) { // DBName can be nil, see #46160
return nil
}
}
```
as we see from the extractTableAlias, when the output name contains two different table, it will abort the extracting logic.
that's why case 7458 couldn't succeed.

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.