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

Improve the performance of WindowExec by using sliding window or segment tree #12967

Closed
7 tasks done
SunRunAway opened this issue Oct 28, 2019 · 24 comments
Closed
7 tasks done
Assignees
Labels
challenge-program sig/execution SIG execution type/enhancement The issue or PR belongs to an enhancement.

Comments

@SunRunAway
Copy link
Contributor

SunRunAway commented Oct 28, 2019

Description

TiDB implements window function feature compatible with MySQL (https://dev.mysql.com/doc/refman/8.0/en/window-functions.html). The performance has much space to improve.

Considering implementing an algorithm of sliding window or segment tree within the different frames of the same window partition, when doing the aggregate calculation step.

And here’s a paper to read http://www.vldb.org/pvldb/vol8/p1058-leis.pdf for reference, describing and comparing some effective implementations. A paper reading video (in Chinese) is here(https://www.bilibili.com/video/av70860233). Due to this paper, we have a chance to make a SQL like select sum(a) over (order by b rows between ? preceding and current row) from r; 600% faster.

Goals:

  • Implement an algorithm of sliding window or segment tree within the different frames of the same window partition

Score

  • 3000

Mentor(s)

Recommended Skills

  • SQL Optimization
  • Golang Profiling
  • Code Refactoring

PRs

Framework: #14294

@SunRunAway SunRunAway added type/enhancement The issue or PR belongs to an enhancement. sig/execution SIG execution difficulty/medium labels Oct 28, 2019
@sre-bot sre-bot added the PCP-S1 label Nov 4, 2019
@mmyj
Copy link
Member

mmyj commented Nov 10, 2019

/pick-up-challenge

@sre-bot
Copy link
Contributor

sre-bot commented Nov 10, 2019

@mmyj don't have enough score, pick up failed
Progress 0/400
You may pick up some easy issues first.

@mmyj
Copy link
Member

mmyj commented Nov 13, 2019

/pick-up-challenge

@sre-bot
Copy link
Contributor

sre-bot commented Nov 13, 2019

@mmyj pick up issue success

mmyj added a commit to mmyj/tidb that referenced this issue Dec 10, 2019
mmyj added a commit to mmyj/tidb that referenced this issue Dec 11, 2019
mmyj added a commit to mmyj/tidb that referenced this issue Dec 17, 2019
mmyj added a commit to mmyj/tidb that referenced this issue Dec 17, 2019
mmyj added a commit to mmyj/tidb that referenced this issue Dec 31, 2019
…w or segment tree pingcap#12967

just improve slide window of countOriginal4Int
mmyj added a commit to mmyj/tidb that referenced this issue Jan 1, 2020
mmyj added a commit to mmyj/tidb that referenced this issue Jan 1, 2020
mmyj added a commit to mmyj/tidb that referenced this issue Jan 1, 2020
mmyj added a commit to mmyj/tidb that referenced this issue Jan 1, 2020
mmyj added a commit to mmyj/tidb that referenced this issue Jan 1, 2020
…w or segment tree pingcap#12967

optimize windowFunc.(aggfuncs.SlidingWindowAggFunc)
@you06 you06 changed the title PCP-5: Improve the performance of WindowExec by using sliding window or segment tree Improve the performance of WindowExec by using sliding window or segment tree Feb 29, 2020
@vagetablechicken
Copy link

vagetablechicken commented Sep 5, 2020

/pick-up

avg

@ti-challenge-bot
Copy link

Pick up success.

@mmyj
Copy link
Member

mmyj commented Sep 5, 2020

/pick-up

avg

hi, the slide window interface of the avg aggFunc had been implemented.@vagetablechicken

@mmyj
Copy link
Member

mmyj commented Sep 5, 2020

@SunRunAway please update the todo list, I had been compelated the avg and the xor.

@TszKitLo40
Copy link
Contributor

/pick-up
group_concat

@ti-challenge-bot
Copy link

This issue already picked by vagetablechicken.

@TszKitLo40
Copy link
Contributor

/pick-up
bitxor

@ti-challenge-bot
Copy link

This issue already picked by vagetablechicken.

@vagetablechicken
Copy link

/give-up

ok, give up this issue

@ti-challenge-bot ti-challenge-bot bot removed the picked label Sep 6, 2020
@ti-challenge-bot
Copy link

Give up success.

@TszKitLo40
Copy link
Contributor

Maybe individual issue should be created for each item. Otherwise the issues could not be picked up.

@mmyj
Copy link
Member

mmyj commented Sep 7, 2020

/pick-up

@ti-challenge-bot
Copy link

Pick up success.

@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Sep 7, 2020

@TszKitLo40
Thanks for the reminder.
I've updated the progress in the description, this is only one subtask remained which is working in progress. Thus we'll not create new issues for the sub-tasks.

@qw4990
Copy link
Contributor

qw4990 commented Sep 9, 2020

It seems all issues of this sliding window optimization have been completed 🎊 !
Can we close this issue now? @SunRunAway @mmyj

@ti-challenge-bot

This comment has been minimized.

@ichn-hu
Copy link
Contributor

ichn-hu commented Feb 24, 2021

for bitOr, bitAnd: no inverse operation, cannot I think you can use segment tree to calculate (as long as the operator is addictive, segment tree can always help), so it is not can not, but let's see if there is any volunteer who want to help implement this.

@TszKitLo40
Copy link
Contributor

for bitOr, bitAnd: no inverse operation, cannot I think you can use segment tree to calculate (as long as the operator is addictive, segment tree can always help), so it is not can not, but let's see if there is any volunteer who want to help implement this.

I want to implement this. But it seems that I need more background knowledge of this issue.

@ichn-hu
Copy link
Contributor

ichn-hu commented Feb 24, 2021

for bitOr, bitAnd: no inverse operation, cannot I think you can use segment tree to calculate (as long as the operator is addictive, segment tree can always help), so it is not can not, but let's see if there is any volunteer who want to help implement this.

I want to implement this. But it seems that I need more background knowledge of this issue.

Thanks for the quick reply, but I am currently refactoring the window funcion framework, which is about to be changed fundamentally, so I would suggest you to implement this later (after my refactorization).

I'll keep you informed for the process of the refactoring, and I'll let you know about the new design doc once it is ready to release.

Please expect to work on this after 3.12, which is the deadline the refactoring should be done.

Does this sounds good to you?

@TszKitLo40
Copy link
Contributor

TszKitLo40 commented Feb 24, 2021

for bitOr, bitAnd: no inverse operation, cannot I think you can use segment tree to calculate (as long as the operator is addictive, segment tree can always help), so it is not can not, but let's see if there is any volunteer who want to help implement this.

I want to implement this. But it seems that I need more background knowledge of this issue.

Thanks for the quick reply, but I am currently refactoring the window funcion framework, which is about to be changed fundamentally, so I would suggest you to implement this later (after my refactorization).

I'll keep you informed for the process of the refactoring, and I'll let you know about the new design doc once it is ready to release.

Please expect to work on this after 3.12, which is the deadline the refactoring should be done.

Does this sounds good to you?

ok, I will wait for your further response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
challenge-program sig/execution SIG execution type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

No branches or pull requests

10 participants