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] Optimize performance of arrays_overlaping #49668

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

trueeyu
Copy link
Contributor

@trueeyu trueeyu commented Aug 9, 2024

Why I'm doing:

Datum is not an efficient data structure, and arrrasy_overlapping heavily relies on Datum for processing, resulting in poor performance.

The second parameter of arrrasy_overlapping is usually const, but there is currently no special handling.

What I'm doing:

PerformaceTest: 27.76s -> 2.74s

mysql> select count(*) from lineorder;
+-----------+
| count(*)  |
+-----------+
| 143999468 |
+-----------+
1 row in set (5.17 sec)

CREATE TABLE `t2` (
  `c1` bigint(20) NOT NULL COMMENT "",
  `c2` array<varchar(65533)> NOT NULL COMMENT "",
  `c3` array<varchar(65533)> NOT NULL COMMENT ""
) ENGINE=OLAP 
DUPLICATE KEY(`c1`)
DISTRIBUTED BY HASH(`c1`) BUCKETS 1 
PROPERTIES (
"compression" = "LZ4",
"fast_schema_evolution" = "true",
"replicated_storage" = "true",
"replication_num" = "1"
);

insert into t2 select lo_orderkey, array_agg(lo_partkey), array_agg(lo_suppkey) from lineorder group by lo_orderkey;

mysql> select count(*) from t2;
+----------+
| count(*) |
+----------+
| 30000000 |
+----------+
1 row in set (0.36 sec)

Before optimization: 27.76s

mysql> select count(*) from t2 where arrays_overlap(c2, ["1", "11", "111", "1111", "11111", "111111", "1111111"]);                                                                                                                                                                
+----------+                                                                                                                                                                                                                                                                      
| count(*) |                                                                                                                                                                                                                                                                      
+----------+                                                                                                                                                                                                                                                                      
|     1204 |                                                                                                                                                                                                                                                                      
+----------+                                                                                                                                                                                                                                                                      
1 row in set (27.76 sec)  

After optimization: 2.74s

mysql> select count(*) from t2 where arrays_overlap(c2, ["1", "11", "111", "1111", "11111", "111111", "1111111"]);                                                                                                                                                                
+----------+                                                                                                                                                                                                                                                                      
| count(*) |                                                                                                                                                                                                                                                                      
+----------+                                                                                                                                                                                                                                                                      
|     1204 |                                                                                                                                                                                                                                                                      
+----------+                                                                                                                                                                                                                                                                      
1 row in set (2.74 sec)

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.3
    • 3.2
    • 3.1
    • 3.0
    • 2.5

Documentation PRs only:

If you are submitting a PR that adds or changes English documentation and have not
included Chinese documentation, then you can check the box to request GPT to translate the
English doc to Chinese. Please ensure to uncheck the Do not translate box if translation is needed.
The workflow will generate a new PR with the Chinese translation after this PR is merged.

  • Yes, translate English markdown files with GPT
  • Do not translate

@mergify mergify bot assigned trueeyu Aug 9, 2024
@trueeyu trueeyu force-pushed the arrays_overlapping_opt branch 2 times, most recently from 02d0b7b to a9de696 Compare August 12, 2024 12:00
@trueeyu trueeyu changed the title [Test] Arrays overlapping opt [Test] Optimize performance of arrays_overlaping Sep 20, 2024
@trueeyu trueeyu changed the title [Test] Optimize performance of arrays_overlaping [Enhancement] Optimize performance of arrays_overlaping Sep 20, 2024
@trueeyu trueeyu marked this pull request as ready for review September 20, 2024 07:11
@trueeyu trueeyu requested review from a team as code owners September 20, 2024 07:11
@trueeyu
Copy link
Contributor Author

trueeyu commented Sep 23, 2024

@Mergifyio rebase main

Copy link
Contributor

mergify bot commented Sep 23, 2024

rebase main

✅ Branch has been successfully rebased

@trueeyu
Copy link
Contributor Author

trueeyu commented Sep 24, 2024

@Mergifyio rebase main

Copy link
Contributor

mergify bot commented Sep 24, 2024

rebase main

✅ Branch has been successfully rebased

@trueeyu
Copy link
Contributor Author

trueeyu commented Sep 25, 2024

https://github.com/Mergifyio rebase main

Copy link
Contributor

mergify bot commented Sep 25, 2024

rebase main

✅ Branch has been successfully rebased

@trueeyu
Copy link
Contributor Author

trueeyu commented Sep 25, 2024

https://github.com/Mergifyio rebase main

Copy link
Contributor

mergify bot commented Sep 25, 2024

rebase main

✅ Branch has been successfully rebased

@trueeyu
Copy link
Contributor Author

trueeyu commented Sep 25, 2024

https://github.com/Mergifyio rebase main

Copy link
Contributor

mergify bot commented Sep 25, 2024

rebase main

✅ Branch has been successfully rebased

@trueeyu
Copy link
Contributor Author

trueeyu commented Sep 25, 2024

https://github.com/Mergifyio rebase main

Copy link

[FE Incremental Coverage Report]

pass : 0 / 0 (0%)

Copy link

[BE Incremental Coverage Report]

pass : 126 / 133 (94.74%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 be/src/column/column_helper.h 12 15 80.00% [352, 353, 354]
🔵 be/src/exprs/array_functions.tpp 109 113 96.46% [331, 345, 379, 405]
🔵 be/src/exprs/function_context.cpp 1 1 100.00% []
🔵 be/src/exprs/array_functions.h 4 4 100.00% []

@silverbullet233 silverbullet233 enabled auto-merge (squash) September 26, 2024 08:44
@silverbullet233 silverbullet233 merged commit 20d8075 into StarRocks:main Sep 26, 2024
50 of 51 checks passed
@trueeyu
Copy link
Contributor Author

trueeyu commented Sep 29, 2024

https://github.com/Mergifyio backport branch-3.3

@github-actions github-actions bot added the 3.3 label Sep 29, 2024
Copy link
Contributor

mergify bot commented Sep 29, 2024

backport branch-3.3

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Sep 29, 2024
trueeyu added a commit that referenced this pull request Sep 30, 2024
wanpengfei-git pushed a commit that referenced this pull request Sep 30, 2024
@trueeyu
Copy link
Contributor Author

trueeyu commented Sep 30, 2024

https://github.com/Mergifyio backport branch-3.2

Copy link
Contributor

mergify bot commented Sep 30, 2024

backport branch-3.2

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Sep 30, 2024
wanpengfei-git pushed a commit that referenced this pull request Sep 30, 2024
@trueeyu
Copy link
Contributor Author

trueeyu commented Sep 30, 2024

https://github.com/Mergifyio backport branch-3.1

Copy link
Contributor

mergify bot commented Sep 30, 2024

backport branch-3.1

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Sep 30, 2024
Signed-off-by: trueeyu <[email protected]>
(cherry picked from commit 20d8075)

# Conflicts:
#	be/src/exprs/array_functions.tpp
wanpengfei-git pushed a commit that referenced this pull request Sep 30, 2024
renzhimin7 pushed a commit to renzhimin7/starrocks that referenced this pull request Nov 7, 2024
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.

4 participants