Improve the performance of `sum(int)` in TiFlash
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1k
- Forks
- 423
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 24
Description
Enhancement
Currently, in TiFlash the result type of sum(int) is bigint, and the result type of sum(decimal) is decimal, in TiDB/MySQL, sum(int) will return decimal. In order to make TiFlash compatible with TiDB/MySQL, the planner in TiDB add an implict cast of sum(int) when pushdown to TiFlash like
sum(cast(int as decimal)).(Note we can not add cast after sum like cast(sum(int) as decimal) because sum(int) may overflow.)
This brings an extra cost when calculating sum(int) in TiFlash, which may hurt the performance a little bit. Ideally, we should change the behavior of sum(int) in TiFLash so it can return decimal directly.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating TiFlash's implementation of sum(int) and the planner path involved in the pushdown cast described in the issue. Compare the existing sum(int) and sum(decimal) behavior with TiDB/MySQL expectations, then verify that sum(int) returns decimal directly without overflow-related regressions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, mysql
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100