Skip to content
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

Merged
merged 2 commits into from
Nov 8, 2022

Conversation

qw4990
Copy link
Contributor

@qw4990 qw4990 commented Nov 7, 2022

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

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Nov 7, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • Reminiscent
  • chrysan

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 7, 2022
@qw4990 qw4990 added sig/planner SIG: Planner epic/cost-model the optimizer cost model and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 7, 2022
@@ -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"
Copy link
Contributor Author

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",
Copy link
Contributor Author

@qw4990 qw4990 Nov 7, 2022

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",
Copy link
Contributor Author

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"
Copy link
Contributor Author

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",
Copy link
Contributor Author

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",
Copy link
Contributor Author

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))",
Copy link
Contributor Author

@qw4990 qw4990 Nov 7, 2022

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.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 7, 2022
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Nov 7, 2022
@qw4990
Copy link
Contributor Author

qw4990 commented Nov 8, 2022

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 170484b

@ti-chi-bot ti-chi-bot added status/can-merge Indicates a PR has been approved by a committer. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 8, 2022
@ti-chi-bot ti-chi-bot merged commit 3ad6f93 into pingcap:master Nov 8, 2022
@sre-bot
Copy link
Contributor

sre-bot commented Nov 8, 2022

TiDB MergeCI notify

✅ Well Done! New fixed [1] after this pr merged.

CI Name Result Duration Compare with Parent commit
idc-jenkins-ci-tidb/integration-ddl-test 🔴 failed 1, success 5, total 6 43 min Existing failure
idc-jenkins-ci/integration-cdc-test 🔴 failed 1, success 38, total 39 23 min Existing failure
idc-jenkins-ci-tidb/mybatis-test 🔴 failed 1, success 0, total 1 10 min Existing failure
idc-jenkins-ci-tidb/common-test ✅ all 11 tests passed 12 min Fixed
idc-jenkins-ci-tidb/integration-common-test 🟢 all 17 tests passed 13 min Existing passed
idc-jenkins-ci-tidb/tics-test 🟢 all 1 tests passed 7 min 23 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-2 🟢 all 28 tests passed 5 min 2 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-1 🟢 all 26 tests passed 4 min 12 sec Existing passed
idc-jenkins-ci-tidb/integration-compatibility-test 🟢 all 1 tests passed 3 min 16 sec Existing passed
idc-jenkins-ci-tidb/plugin-test 🟢 build success, plugin test success 4min Existing passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epic/cost-model the optimizer cost model release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants