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 to cost model2 #38893

Merged
merged 5 commits into from
Nov 5, 2022

Conversation

qw4990
Copy link
Contributor

@qw4990 qw4990 commented Nov 4, 2022

What problem does this PR solve?

Issue Number: ref #35240

Problem Summary: planner: update some UTs to cost model2

What is changed and how it works?

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 4, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • Yisaer
  • time-and-fate

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/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 4, 2022
@qw4990 qw4990 added sig/planner SIG: Planner epic/cost-model the optimizer cost model and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 4, 2022
@ti-chi-bot ti-chi-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Nov 4, 2022
@@ -745,12 +745,12 @@
{
"name": "TestPushDownProjectionForTiFlash",
"cases": [
"desc format = 'brief' select /*+ hash_agg()*/ count(b) from (select id + 1 as b from t)A",
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 add some hints to fix them to use TiFlash.

" ├─TopN(Build) 3.00 cop[tikv] test.tbl.b:desc, offset:0, count:3",
" │ └─IndexRangeScan 4.00 cop[tikv] table:tbl, index:idx_b_c(b, c) range:(1,+inf], keep order:false",
" └─TableRowIDScan(Probe) 3.00 cop[tikv] table:tbl keep order:false"
"Limit 1.00 root offset:2, count:1",
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, Limit+Order is better than TopN.

@@ -4878,13 +4879,13 @@
"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, the current build-side has the smaller row-size which results in a smaller hash-build-cost.

"└─TableReader 10000.00 root data:TableFullScan",
" └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo"
"TableReader 10000.00 root data:Projection",
"└─Projection 10000.00 cop[tikv] md5(test.t.s)->Column#13",
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, pushing the Projection down can result a smaller cost.

"│ └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo",
"└─Projection(Probe) 10000.00 root minus(test.t.id, 2)->Column#9",
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, the current build-side has the smaller row-size which results in a smaller hash-build-cost.

" └─HashAgg 8000.00 mpp[tiflash] group by:test.t.id, funcs:sum(Column#21)->Column#20, funcs:sum(Column#22)->Column#5, funcs:firstrow(test.t.id)->test.t.id",
" └─ExchangeReceiver 8000.00 mpp[tiflash] ",
" └─ExchangeSender 8000.00 mpp[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.t.id, collate: binary]",
" └─HashAgg 8000.00 mpp[tiflash] group by:Column#26, funcs:count(Column#24)->Column#21, funcs:sum(Column#25)->Column#22",
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, 2Phase-Agg is better than 1Phase-Agg in this case.

" └─HashAgg 8000.00 mpp[tiflash] group by:test.t.id, funcs:sum(Column#12)->Column#5, funcs:firstrow(test.t.id)->test.t.id",
" └─ExchangeReceiver 8000.00 mpp[tiflash] ",
" └─ExchangeSender 8000.00 mpp[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.t.id, collate: binary]",
" └─HashAgg 8000.00 mpp[tiflash] group by:test.t.id, funcs:count(1)->Column#12",
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, 2Phase-Agg is better than 1Phase-Agg in this case.

" └─TableFullScan_18 10000.00 255000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo"
"StreamAgg_10 1.00 65360.67 root funcs:count(1)->Column#4",
"└─TableReader_24 10.00 64861.67 root data:Selection_23",
" └─Selection_23 10.00 972291.38 cop[tiflash] eq(test.t.a, 1)",
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, no need to push the Agg down since there are only 10 rows.

" └─TableFullScan_20 10000.00 255000.00 mpp[tiflash] table:t keep order:false, stats:pseudo"
"StreamAgg_12 1.00 65360.67 root funcs:count(1)->Column#4",
"└─TableReader_31 10.00 64861.67 root data:Selection_30",
" └─Selection_30 10.00 972291.38 cop[tiflash] eq(test.t.a, 1)",
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, no need to push the Agg down since there are only 10 rows.

" └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo"
"HashAgg 8000.00 root group by:Column#7, funcs:count(Column#8)->Column#6",
"└─IndexReader 8000.00 root index:HashAgg",
" └─HashAgg 8000.00 cop[tikv] group by:md5(cast(test.t.a, var_string(20))), funcs:count(test.t.a)->Column#8",
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, pushding this Agg down is better in this case.

" └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo"
"StreamAgg 1.00 root funcs:count(Column#8)->Column#6",
"└─TableReader 1.00 root data:StreamAgg",
" └─StreamAgg 1.00 cop[tikv] funcs:count(test.t.a)->Column#8",
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, pushding this Agg down is better in this case.

" │ └─HashAgg_29 8000.00 mpp[tiflash] group by:test.o.c_id, funcs:sum(Column#8)->Column#7, funcs:firstrow(test.o.c_id)->test.o.c_id",
" │ └─ExchangeReceiver_31 8000.00 mpp[tiflash] ",
" │ └─ExchangeSender_30 8000.00 mpp[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.o.c_id, collate: binary]",
" │ └─HashAgg_20 8000.00 mpp[tiflash] group by:test.o.c_id, funcs:count(1)->Column#8",
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, pushding this Agg down is better in this case.

" │ └─HashAgg_30 8000.00 mpp[tiflash] group by:test.o.c_id, test.o.o_id, funcs:sum(Column#9)->Column#7, funcs:firstrow(test.o.o_id)->Column#8, funcs:firstrow(test.o.o_id)->test.o.o_id, funcs:firstrow(test.o.c_id)->test.o.c_id",
" │ └─ExchangeReceiver_32 8000.00 mpp[tiflash] ",
" │ └─ExchangeSender_31 8000.00 mpp[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.o.o_id, collate: binary], [name: test.o.c_id, collate: binary]",
" │ └─HashAgg_21 8000.00 mpp[tiflash] group by:test.o.c_id, test.o.o_id, funcs:count(1)->Column#9",
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, pushding this Agg down is better in this case.

@@ -1169,10 +1162,10 @@
{
"SQL": "EXPLAIN select count(distinct b), json_objectagg(d,c) from t;",
"Plan": [
"StreamAgg_7 1.00 root funcs:count(distinct Column#9)->Column#7, funcs:json_objectagg(Column#10, Column#11)->Column#8",
"HashAgg_6 1.00 root funcs:count(distinct Column#9)->Column#7, funcs:json_objectagg(Column#10, Column#11)->Column#8",
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 since the data size to process is not small(10000).

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 4, 2022
@ti-chi-bot ti-chi-bot removed the status/LGT1 Indicates that a PR has LGTM 1. label Nov 4, 2022
@ti-chi-bot ti-chi-bot added the status/LGT2 Indicates that a PR has LGTM 2. label Nov 4, 2022
@hawkingrei
Copy link
Member

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: b48d20a

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Nov 5, 2022
@hawkingrei
Copy link
Member

/run-build

@ti-chi-bot ti-chi-bot merged commit d323b8d into pingcap:master Nov 5, 2022
@sre-bot
Copy link
Contributor

sre-bot commented Nov 5, 2022

TiDB MergeCI notify

🔴 Bad News! [1] CI still failing after this pr merged.
These failed integration tests don't seem to be introduced by the current PR.

CI Name Result Duration Compare with Parent commit
idc-jenkins-ci/integration-cdc-test 🔴 failed 5, success 34, total 39 19 min Existing failure
idc-jenkins-ci-tidb/integration-ddl-test 🟢 all 6 tests passed 23 min Existing passed
idc-jenkins-ci-tidb/integration-common-test 🟢 all 17 tests passed 12 min Existing passed
idc-jenkins-ci-tidb/common-test 🟢 all 11 tests passed 9 min 6 sec Existing passed
idc-jenkins-ci-tidb/tics-test 🟢 all 1 tests passed 5 min 58 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-1 🟢 all 26 tests passed 5 min 56 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-2 🟢 all 28 tests passed 5 min 38 sec Existing passed
idc-jenkins-ci-tidb/mybatis-test 🟢 all 1 tests passed 3 min 7 sec Existing passed
idc-jenkins-ci-tidb/integration-compatibility-test 🟢 all 1 tests passed 2 min 47 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/XL Denotes a PR that changes 500-999 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.

6 participants