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

expression: support disable expression pushdown based on store type #16389

Merged
merged 22 commits into from
Apr 17, 2020

Conversation

windtalker
Copy link
Contributor

@windtalker windtalker commented Apr 15, 2020

What problem does this PR solve?

Issue Number: close #16353, close #16504

Problem Summary:
TiDB support expr pushdown blacklist, if the expr is added to mysql.expr_pushdown_blacklist, then it will not be pushed to cop layer, however, this blacklist does not take store type into acount, so it is impossible to disable an expr pushdown to a specified store(like tikv or tiflash)

What is changed and how it works?

What's Changed:
Add two columns store_type and reason to mysql.expr_pushdown_blacklist
How it Works:
store_type in mysql.expr_pushdown_blacklist indicates which store should the expr pushdown be disabled

Check List

Tests

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

Release note

@windtalker windtalker requested a review from a team as a code owner April 15, 2020 05:13
@ghost ghost requested review from wshwsh12 and removed request for a team April 15, 2020 05:13
@windtalker windtalker requested a review from a team as a code owner April 15, 2020 05:28
@ghost ghost requested review from francis0407 and removed request for a team April 15, 2020 05:28
@codecov
Copy link

codecov bot commented Apr 15, 2020

Codecov Report

Merging #16389 into master will decrease coverage by 0.2605%.
The diff coverage is 88.3116%.

@@               Coverage Diff                @@
##             master     #16389        +/-   ##
================================================
- Coverage   80.6470%   80.3864%   -0.2606%     
================================================
  Files           506        506                
  Lines        137643     136666       -977     
================================================
- Hits         111005     109861      -1144     
- Misses        18096      18228       +132     
- Partials       8542       8577        +35     

}
storeTypes := strings.Split(storeTypeString, ",")
for _, typeString := range storeTypes {
if typeString == "tidb" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use the kv.TiDB.Name() instead of "tidb".


func upgradeToVer42(s Session) {
doReentrantDDL(s, "ALTER TABLE mysql.expr_pushdown_blacklist ADD COLUMN `store_type` char(100) NOT NULL DEFAULT 'tikv,tiflash,tidb'", infoschema.ErrColumnExists)
doReentrantDDL(s, "ALTER TABLE mysql.expr_pushdown_blacklist ADD COLUMN `reason` varchar(200)", infoschema.ErrColumnExists)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this column?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to keep this column, since we will add some default rows in expr_pushdown_blacklist, this column can make it self-explained, otherwise, the users may keep asking why those exprs are disabled by default.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to keep this column, since we will add some default rows in expr_pushdown_blacklist, this column can make it self-explained, otherwise, the users may keep asking why those exprs are disabled by default.

Yeah, this explanation is also OK for me.

Comment on lines 4965 to 4969
"Selection_5 2133.33 root lt(test.t.b, 1994-01-01)",
"└─Selection_9 2666.67 root gt(cast(test.t.a), 10.10)",
" └─TableReader_8 2666.67 root data:Selection_7",
" └─Selection_7 2666.67 cop[tiflash] eq(date_format(test.t.b, \"%m\"), \"11\"), gt(test.t.b, 1988-01-01)",
" └─TableFullScan_6 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd better not to compare the explain result directly. That is not friendly enough for other developers. You can get the testkit.rows and compare the expression info in the second-to-last row.

Copy link
Contributor

@lzmhhh123 lzmhhh123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for other changes.

@lzmhhh123 lzmhhh123 added the type/enhancement The issue or PR belongs to an enhancement. label Apr 15, 2020
Copy link
Contributor

@wshwsh12 wshwsh12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wshwsh12 wshwsh12 added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 15, 2020
lzmhhh123
lzmhhh123 previously approved these changes Apr 16, 2020
Copy link
Contributor

@lzmhhh123 lzmhhh123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@windtalker
Copy link
Contributor Author

/run-integration-copr-test

"HashJoin_7 9990.00 root inner join, equal:[eq(test.t.a, test.t.a)]",
"├─Selection_15(Build) 7992.00 root from_unixtime(cast(test.t.b))",
"│ └─TableReader_14 7992.00 root data:Selection_13",
"│ └─Selection_13 7992.00 cop[tikv] not(isnull(test.t.a))",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the estimated output row count is changed from 9990.00 to 7992.00?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is because from_unixtime is now pushed down by predicate pushdown rule, so when estimate output rowcount, the cop task thought it has two filter conditions(is not null and from_unixtime)

@windtalker
Copy link
Contributor Author

/run-integration-copr-test

@windtalker
Copy link
Contributor Author

/run-all-tests

Copy link
Contributor

@lzmhhh123 lzmhhh123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lzmhhh123
Copy link
Contributor

/merge

@sre-bot
Copy link
Contributor

sre-bot commented Apr 17, 2020

/run-all-tests

@sre-bot
Copy link
Contributor

sre-bot commented Apr 17, 2020

@windtalker merge failed.

@lzmhhh123 lzmhhh123 merged commit b8494e7 into pingcap:master Apr 17, 2020
sre-bot pushed a commit to sre-bot/tidb that referenced this pull request Apr 17, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Apr 17, 2020

cherry pick to release-3.1 in PR #16513

@sre-bot
Copy link
Contributor

sre-bot commented Apr 17, 2020

cherry pick to release-4.0 in PR #16514

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression sig/execution SIG execution status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
6 participants