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

[enhancement](Nereids) Speedup PartitionPrunner #31970

Merged
merged 2 commits into from
Mar 8, 2024

Conversation

924060929
Copy link
Contributor

@924060929 924060929 commented Mar 7, 2024

Proposed changes

This pr imporve the high QPS query by speed up PartitionPrunner

  1. remove useless Date parse/format, use LocalDate instead
  2. fast evaluate path for single value partition
  3. change Collection.stream() to ImmutableXxx.builderWithExpectedSize(n) to skip useless method call and collection resize
  4. change lots of if-else to switch
  5. don't parse to string to compare dateLiteral, use int field compare instead

@doris-robot
Copy link

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR

@924060929
Copy link
Contributor Author

run buildall

@wm1581066
Copy link
Collaborator

Any performance data?

@924060929
Copy link
Contributor Author

run buildall

@924060929
Copy link
Contributor Author

run buildall

@924060929
Copy link
Contributor Author

924060929 commented Mar 8, 2024

Any performance data?

100 threads parallel continuous send this sql which query an empty table, test in my mac machine(m2 chip, 8 core)

select  count(1),date_format(time_col,'%Y%m%d'),varchar_col1
from tbl 
where  partition_date>'2024-02-15'  and (varchar_col2 ='73130' or varchar_col3='73130') and time_col>'2024-03-04' 
  and  time_col<'2024-03-05'
group by date_format(time_col,'%Y%m%d'),varchar_col1 
order by date_format(time_col,'%Y%m%d') desc, varchar_col1 desc,count(1) asc
limit 1000

before: 1600 peak QPS, about 1300 avg QPS
after: 3100 peak QPS, about 2700 avg QPS

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Mar 8, 2024
Copy link
Contributor

github-actions bot commented Mar 8, 2024

PR approved by at least one committer and no changes requested.

Copy link
Contributor

github-actions bot commented Mar 8, 2024

PR approved by anyone and no changes requested.

this.slotToType = IntStream.range(0, partitionSlots.size())
.mapToObj(index -> Pair.of(partitionSlots.get(index), partitionSlotTypes.get(index)))
.collect(ImmutableMap.toImmutableMap(Pair::key, Pair::value));
this.slotToType = Maps.newHashMapWithExpectedSize(partitionSlots.size() * 2);
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: use Maps.newHashMapWithExpectedSize(partitionSlots.size()); may good enough, can update the code in next pr

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 will change to 16 in next pr, because the num of partitionSlots usually <= 3

@morrySnow morrySnow merged commit 959b69a into apache:master Mar 8, 2024
27 of 32 checks passed
@924060929 924060929 deleted the optimize_partition_prunner branch March 8, 2024 12:42
yiguolei pushed a commit that referenced this pull request Mar 9, 2024
This pr imporve the high QPS query by speed up PartitionPrunner

1. remove useless Date parse/format, use LocalDate instead
2. fast evaluate path for single value partition
3. change Collection.stream() to ImmutableXxx.builderWithExpectedSize(n) to skip useless method call and collection resize
4. change lots of if-else to switch
5. don't parse to string to compare dateLiteral, use int field compare instead
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by one committer. reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants