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

feat(frontend): Supports cut OR condition and push down to storage #19812

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Li0k
Copy link
Contributor

@Li0k Li0k commented Dec 16, 2024

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

related to #19525

This PR implements the optimizations mentioned in the issue

  1. try to merge scan_range with same eq.
  2. try to push down multiple scan ranges instead of full table scan

Checklist

  • I have written necessary rustdoc comments.
  • I have added necessary unit tests and integration tests.
  • I have added test labels as necessary.
  • I have added fuzzing tests or opened an issue to track them.
  • My PR contains breaking changes.
  • My PR changes performance-critical code, so I will run (micro) benchmarks and present the results.
  • My PR contains critical fixes that are necessary to be merged into the latest release.

Documentation

  • My PR needs documentation updates.
Release note

@Li0k Li0k requested review from chenzl25 and xxhZs December 16, 2024 12:05
@Li0k Li0k changed the title feat(batch): Supports cut OR condition and push down to storage WIP: feat(batch): Supports cut OR condition and push down to storage Dec 16, 2024
@Li0k Li0k marked this pull request as ready for review December 16, 2024 12:08
@graphite-app graphite-app bot requested a review from a team December 16, 2024 12:28
@Li0k Li0k changed the title WIP: feat(batch): Supports cut OR condition and push down to storage WIP: feat(frontend): Supports cut OR condition and push down to storage Dec 17, 2024
@Li0k Li0k changed the title WIP: feat(frontend): Supports cut OR condition and push down to storage feat(frontend): Supports cut OR condition and push down to storage Dec 18, 2024
@Li0k Li0k requested a review from st1page December 18, 2024 03:40
@@ -418,7 +418,7 @@
batch_plan: |-
BatchExchange { order: [], dist: Single }
└─BatchFilter { predicate: (((orders_count_by_user.user_id = 1:Int32) OR ((orders_count_by_user.user_id = 2:Int32) AND In(orders_count_by_user.date, 1111:Int32, 2222:Int32))) OR (orders_count_by_user.user_id <> 3:Int32)) }
└─BatchScan { table: orders_count_by_user, columns: [orders_count_by_user.user_id, orders_count_by_user.date, orders_count_by_user.orders_count], distribution: UpstreamHashShard(orders_count_by_user.user_id, orders_count_by_user.date) }
└─BatchScan { table: orders_count_by_user, columns: [orders_count_by_user.user_id, orders_count_by_user.date, orders_count_by_user.orders_count], scan_ranges: [orders_count_by_user.user_id = Int64(1), orders_count_by_user.user_id = Int64(2) AND orders_count_by_user.date = Int32(1111), orders_count_by_user.user_id = Int64(2) AND orders_count_by_user.date = Int32(2222)], distribution: UpstreamHashShard(orders_count_by_user.user_id, orders_count_by_user.date) }
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this can not be pushed down with condition orders_count_by_user.user_id <> 3:Int32?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I didn't realize that full table scan range would be converted to empty vec, and I fixed it with a special judgment.

@Li0k
Copy link
Contributor Author

Li0k commented Dec 18, 2024

Test:

CREATE TABLE t1(v1 int primary key);

INSERT INTO t1 (v1) SELECT v FROM generate_series(1, 10000000) AS v;

SELECT COUTN(*) FROM t1;

SELECT * FROM t1 WHERE (v1 > 10 AND v1 < 20) OR (v1 > 5000000 AND v1 < 5000100);

before:
image

after:
image

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.

2 participants