pingcap / pingcap/tidb

planner deriveStats is isolated from physical optimization phase, couldn't aware of underlying concrete physical choise

Open
#49,809 0 comments 0 reactions 0 assignees View on GitHub
severity/moderate sig/planner type/enhancement
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Enhancement
```
+----------------------------------+---------+-----------+------------------------+--------------------------------------------------------------------+
| id | estRows | task | access object | operator info |
+----------------------------------+---------+-----------+------------------------+--------------------------------------------------------------------+
| Sort_33 | 0.00 | root | | test.t1.c1 |
| └─IndexMerge_40 | 0.92 | root | | type: union |
| ├─IndexRangeScan_36(Build) | 1.66 | cop[tikv] | table:t1, index:c1(c1) | range:[-inf,10), keep order:false, stats:pseudo |
| ├─IndexRangeScan_37(Build) | 1.66 | cop[tikv] | table:t1, index:c2(c2) | range:[-inf,10), keep order:false, stats:pseudo |
| └─Selection_39(Probe) | 0.92 | cop[tikv] | | or(lt(test.t1.c1, 10), and(lt(test.t1.c2, 10), eq(test.t1.c3, 5))) |
| └─TableRowIDScan_38 | 2.77 | cop[tikv] | table:t1 | keep order:false, stats:pseudo |
+----------------------------------+---------+-----------+------------------------+--------------------------------------------------------------------+
6 rows in set (3 min 1.40 sec)
```

index merge may have many choices when enumerating their physical partial path, the choice of all alternatives can directly affect the countAfterAccess where the main differing cost from, but currently, all (datasource)'s physical implement cost is based on identical row count estimation which is derived from minimum CountAfterAccess when deriveStats before stepping into physical phase.

image

not for the indexMerge case, but for all possible access paths, the physical choosing of access paths should directly have a cost DIFFER on CountAfterAccess as we expected. After that, the cost estimation will be more desirable.

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.