-
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: update some UTs from cost model1 to model2 #38947
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. |
@@ -1834,7 +1834,7 @@ | |||
{ | |||
"SQL": "select * from t1 where a = 3 or a = 5", | |||
"Plan": [ | |||
"Batch_Point_Get_5 2.00 12.53 root table:t1 handle:[3 5], keep order:false, desc:false" |
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.
Expected, just update the cost value, no plan change.
] | ||
}, | ||
{ | ||
"SQL": "explain format = 'brief' select count(*) from fact_t, d1_t, d2_t, d3_t where fact_t.d1_k = d1_t.d1_k and fact_t.d2_k = d2_t.d2_k and fact_t.d3_k = d3_t.d3_k", | ||
"Plan": [ | ||
"HashAgg 1.00 root funcs:count(Column#18)->Column#17", |
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.
Expected, if not much data here, then 1) StreamAgg is better than HashAgg; 2) no need to push the Agg down.
@@ -4187,11 +4171,10 @@ | |||
{ | |||
"SQL": "desc format = 'brief' select avg(a) from t", | |||
"Plan": [ | |||
"StreamAgg 1.00 root funcs:avg(Column#7, Column#8)->Column#4", |
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.
Expected, HashAgg is better than StreamAgg if much data to process (10000 rows here).
@@ -4269,7 +4252,7 @@ | |||
"SQL": "desc format = 'brief' select * from tt where (tt.a > 1 and tt.a < 20) or (tt.a >= 30 and tt.a < 55)", | |||
"Plan": [ | |||
"TableReader 44.00 root data:TableRangeScan", | |||
"└─TableRangeScan 44.00 cop[tiflash] table:tt range:(1,20), [30,55), keep order:false, stats:pseudo" |
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.
Expected, model2 prefers to use TiKV Scan if not much data to scan.
@@ -4675,11 +4658,11 @@ | |||
"SQL": "desc format = 'brief' select * from t right join (select id-2 as b from t) A on A.b=t.id", | |||
"Plan": [ | |||
"HashJoin 12487.50 root right outer join, equal:[eq(test.t.id, Column#25)]", | |||
"├─TableReader(Build) 9990.00 root data:Selection", |
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.
Expected, model2 takes row-size into consideration when calculating HashJoin costs.
@@ -5430,20 +5413,22 @@ | |||
" │ └─ExchangeSender 7976.02 mpp[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.t.c1, collate: binary], [name: Column#58, collate: binary], [name: test.t.c5, collate: binary]", | |||
" │ └─Projection 7976.02 mpp[tiflash] Column#7, test.t.c1, test.t.c2, test.t.c5, cast(test.t.c2, decimal(10,5))->Column#58", | |||
" │ └─Projection 7976.02 mpp[tiflash] Column#7, test.t.c1, test.t.c2, test.t.c5", | |||
" │ └─HashAgg 7976.02 mpp[tiflash] group by:test.t.c1, test.t.c2, test.t.c5, funcs:count(1)->Column#7, funcs:firstrow(test.t.c1)->test.t.c1, funcs:firstrow(test.t.c2)->test.t.c2, funcs:firstrow(test.t.c5)->test.t.c5", |
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.
Expected, 2PhaseAgg is better than 1PhaseAgg here.
@@ -350,9 +350,9 @@ | |||
}, | |||
{ | |||
"SQL": "select /*+ USE_INDEX_MERGE(t1, c_d_e, f_g) */ * from t where c < 1 or f > 2", | |||
"Best": "IndexMergeReader(PartialPlans->[Index(t.c_d_e)[[-inf,1)], Index(t.f)[(2,+inf]]], TablePlan->Table(t))", |
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.
Expected, since the Hint here is not correct, model2 prefers to use single-read plans(Table/IndexScan) instead of double-read plans(IndexLookup/IndexMerge/IndexJoin) to reduce the risks of large double-read requests.
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 170484b
|
TiDB MergeCI notify✅ Well Done! New fixed [1] after this pr merged.
|
What problem does this PR solve?
Issue Number: ref #35240
Problem Summary: planner: update some UTs from cost model1 to model2
What is changed and how it works?
planner: update some UTs from cost model1 to model2
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.