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: open CAST push down switcher default #12652

Merged
merged 31 commits into from Nov 7, 2019
Merged

expression: open CAST push down switcher default #12652

merged 31 commits into from Nov 7, 2019

Conversation

lonng
Copy link
Contributor

@lonng lonng commented Oct 12, 2019

Signed-off-by: Lonng heng@lonng.org

What problem does this PR solve?

Open the CAST push-down switcher and fix some execution plans.

What is changed and how it works?

We have fixed all CAST functions related inconsistent between TiDB and TiKV, it's time to open the switcher default.

Check List

Tests

  • Unit test
  • Integration test

Release note

Signed-off-by: Lonng <heng@lonng.org>
@SunRunAway SunRunAway removed their request for review October 12, 2019 08:50
@lonng lonng requested a review from a team as a code owner October 16, 2019 05:12
@ghost ghost requested review from XuHuaiyu and removed request for a team October 16, 2019 05:12
Signed-off-by: H-ZeX <hzx20112012@gmail.com>
Signed-off-by: H-ZeX <hzx20112012@gmail.com>
Signed-off-by: H-ZeX <hzx20112012@gmail.com>
@codecov
Copy link

codecov bot commented Oct 16, 2019

Codecov Report

Merging #12652 into master will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##            master    #12652   +/-   ##
=========================================
  Coverage   80.181%   80.181%           
=========================================
  Files          469       469           
  Lines       111555    111555           
=========================================
  Hits         89446     89446           
  Misses       15200     15200           
  Partials      6909      6909

@H-ZeX
Copy link
Contributor

H-ZeX commented Oct 16, 2019

/run-all-tests tidb-test=pr/918

@Deardrops
Copy link
Contributor

LGTM

@lonng
Copy link
Contributor Author

lonng commented Nov 7, 2019

Coprocessor integration test: tikv/copr-test#4

data = types.Datum{}
data.SetMysqlDecimal(to)
if err != nil {
return data, err
Copy link
Contributor

Choose a reason for hiding this comment

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

Why put return after creating data? If err != nil, to is not even integral.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we should return the data even though overflow occurred (the caller should handle it in a proper way if the err is overflow or truncated).

@@ -54,7 +55,7 @@ func (d *distinctChecker) Check(values []types.Datum) (bool, error) {
}

// calculateSum adds v to sum.
func calculateSum(sc *stmtctx.StatementContext, sum, v types.Datum) (data types.Datum, err error) {
func calculateSum(sc *stmtctx.StatementContext, sum, v types.Datum, retType *types.FieldType) (data types.Datum, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the relationship between pushdown CAST and calculateSum? Are there any test cases for sum?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are many test cases that will cover the sum (query with sum/avg aggregation functions). The is no direct relationship with CAST and sum and I modify it because of the previous implementation does not round appropriately (this BUG is detected by this PR).

@djshow832
Copy link
Contributor

LGTM

Copy link
Contributor

@Deardrops Deardrops left a comment

Choose a reason for hiding this comment

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

LGTM

@lonng
Copy link
Contributor Author

lonng commented Nov 7, 2019

/run-all-tests tidb-test=pr/940

@lonng
Copy link
Contributor Author

lonng commented Nov 7, 2019

/run-integration-common-test tidb-test=pr/940

js, err := json.Marshal(pbExpr)
c.Assert(err, IsNil)
c.Assert(string(js), Equals, "null")
c.Assert(string(js), Equals, expects[i])
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this result change?

@lonng
Copy link
Contributor Author

lonng commented Nov 7, 2019

/run-integration-common-test tidb-test=pr/940

@lonng
Copy link
Contributor Author

lonng commented Nov 7, 2019

/run-all-tests tidb-test=pr/940

@lonng lonng merged commit a785493 into pingcap:master Nov 7, 2019
@lonng lonng deleted the cast-push-down branch November 7, 2019 12:07
breezewish added a commit that referenced this pull request Nov 7, 2019
breezewish added a commit that referenced this pull request Nov 8, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Nov 8, 2019

Benchmark Report

Run Sysbench Performance Test on VMs

@@                               Benchmark Diff                               @@
================================================================================
--- tidb: 79756747e706c2c706ecb00e8f1459796295656c
+++ tidb: a04215ca624cf90b2228882fbb49b4abbcbfd5cd
tikv: 1999eaf8a6da5d4d7cc8f89a0d1127c516614aef
pd: d6d08d9b58fa42a29c3b3f517b9a64a562475588
================================================================================
oltp_update_non_index:
    * QPS: 4712.26 ± 0.35% (std=10.55) delta: 0.01% (p=0.949)
    * Latency p50: 27.16 ± 0.36% (std=0.06) delta: 0.00%
    * Latency p99: 42.43 ± 4.09% (std=1.14) delta: 2.00%
            
oltp_insert:
    * QPS: 3883.00 ± 0.82% (std=20.38) delta: -0.79% (p=0.151)
    * Latency p50: 32.96 ± 0.81% (std=0.17) delta: 0.80%
    * Latency p99: 75.82 ± 0.00% (std=0.00) delta: 0.90%
            
oltp_read_write:
    * QPS: 15614.20 ± 0.14% (std=19.90) delta: 0.29% (p=0.118)
    * Latency p50: 164.30 ± 0.14% (std=0.21) delta: -0.26%
    * Latency p99: 323.08 ± 0.90% (std=2.91) delta: -0.30%
            
oltp_update_index:
    * QPS: 4257.40 ± 0.02% (std=0.62) delta: 0.09% (p=0.300)
    * Latency p50: 30.06 ± 0.07% (std=0.01) delta: -0.10%
    * Latency p99: 54.83 ± 0.00% (std=0.00) delta: 3.66%
            
oltp_point_select:
    * QPS: 50142.42 ± 0.46% (std=183.88) delta: 0.23% (p=0.631)
    * Latency p50: 2.55 ± 0.39% (std=0.01) delta: -0.29%
    * Latency p99: 8.90 ± 0.00% (std=0.00) delta: 0.45%
            

XiaTianliang pushed a commit to XiaTianliang/tidb that referenced this pull request Dec 21, 2019
XiaTianliang pushed a commit to XiaTianliang/tidb that referenced this pull request Dec 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants