Skip to content

optimize Date format (#1337)#1339

Merged
ti-srebot merged 10 commits intopingcap:release-4.0from
ti-srebot:release-4.0-f452ab35ada7
Jan 20, 2021
Merged

optimize Date format (#1337)#1339
ti-srebot merged 10 commits intopingcap:release-4.0from
ti-srebot:release-4.0-f452ab35ada7

Conversation

@ti-srebot
Copy link
Collaborator

cherry-pick #1337 to release-4.0

What problem does this PR solve?

Problem Summary:

DateFormat is slow in TiFlash, need to optimize it.

What is changed and how it works?

What's Changed:

How it Works:

  1. avoid all sprintf in MyTimeBase::dateFormat
  2. precompile format string to avoid parsing format string everytime
  3. pre-allocate && reuse string capacity in FunctionDateFormat

Result:

on TPCH-20, with batchcop

query with optimize without optimize
select count(date_format(L_SHIPDATE, '%Y-%m-%d')) from lineitem 1.26 sec 5.14 sec

Related changes

Check List

Tests

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

Side effects

Release note

  • optimize the performance of date_format function in TiFlash

@leiysky
Copy link
Contributor

leiysky commented Jan 19, 2021

LGTM

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Jan 19, 2021
Copy link
Contributor

@zanmato1984 zanmato1984 left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jan 19, 2021
@windtalker windtalker added the status/can-merge Indicates a PR has been approved by a committer. label Jan 19, 2021
@ti-srebot
Copy link
Collaborator Author

/run-all-tests

@windtalker
Copy link
Contributor

/merge

@windtalker
Copy link
Contributor

/run-all-tests

@ti-srebot ti-srebot merged commit c0e1b09 into pingcap:release-4.0 Jan 20, 2021
@windtalker windtalker added this to the v4.0.11 milestone Jan 20, 2021
@windtalker windtalker deleted the release-4.0-f452ab35ada7 branch January 20, 2021 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CHERRY-PICK cherry pick 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.

4 participants