-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
planner: introduce new cost formula for Selection/TableScan/IndexScan #35378
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Code Coverage Details: https://codecov.io/github/pingcap/tidb/commit/09678e9a964beb3b01a3ec19c75929980961c033 |
planner/core/plan_cost.go
Outdated
scanFactor = p.ctx.GetSessionVars().GetDescScanFactor(p.Table) | ||
} | ||
} | ||
rowSize := math.Max(p.getScanRowSize(), 2.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why cannot rowSize
exceed 2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To guarantee logRowSize >= 1
.
} | ||
} | ||
rowSize := math.Max(p.getScanRowSize(), 2.0) | ||
logRowSize := math.Log2(rowSize) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log2 in the formula is based on experiment results?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YES, I'll add some comments here.
var scanFactor float64 | ||
switch taskType { | ||
case property.MppTaskType: // use a dedicated scan-factor for TiFlash | ||
scanFactor = p.ctx.GetSessionVars().GetTiFlashScanFactor() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we assume that there is little performance difference between Scan
and DescScan
on TiFlash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, no need to distinguish Scan
and DescScan
for TiFlash
for now. I'll add some comments.
Some comments were added, PTAL @xuyifangreeneyes |
/run-unit-test |
/merge |
1 similar comment
/merge |
This pull request has been accepted and is ready to merge. Commit hash: d59348e
|
1 similar comment
This pull request has been accepted and is ready to merge. Commit hash: d59348e
|
TiDB MergeCI notify🔴 Bad News! [1] CI still failing after this pr merged.
|
What problem does this PR solve?
Issue Number: ref #35240
Problem Summary: introduce new cost formula for Selection/TableScan/IndexScan
What is changed and how it works?
Introduce new cost formula for Selection/TableScan/IndexScan.
On cost model ver2:
rows*cpu-factor
->rows*num-filters*cpu-factor
; use a dedicatedcpu-factor
for TiFlash;rows*row-size*scan-factor
->rows*log(row-size)*scan-factor
; use a dedicatedscan-factor
for TiFlash;rows*row-size*scan-factor
->rows*log(row-size)*scan-factor
;I'll add tests after finishing cost model ver2.
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.