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(optimizer): support better predicate pushdown for table scan #19525

Open
chenzl25 opened this issue Nov 21, 2024 · 1 comment
Open

feat(optimizer): support better predicate pushdown for table scan #19525

chenzl25 opened this issue Nov 21, 2024 · 1 comment
Assignees
Milestone

Comments

@chenzl25
Copy link
Contributor

chenzl25 commented Nov 21, 2024

Is your feature request related to a problem? Please describe.

If a predicate contains or, currently our optimizer failed to push them to storage which leads to poor performance. We can improve the performance by pushing predicate to storage and keep the original predicate on top of the scan.
PS: please note that we need to ensure each arm of the or condition is non-overlap.

create table t(id int primary key, name varchar);
-- We should push predicate id = 1 or id = 2 to storage.
explain select * from t where id = 1 or (id = 2 and name = 'x');

                                            QUERY PLAN
--------------------------------------------------------------------------------------------------
 BatchExchange { order: [], dist: Single }
 └─BatchFilter { predicate: ((t.id = 1:Int32) OR ((t.id = 2:Int32) AND (t.name = 'x':Varchar))) }
   └─BatchScan { table: t, columns: [id, name] }
(3 rows)


-- We should push predicate id > 10001 or id = 10000 to storage.
select * from t where id > 10001 or (id = 10000 and name = 'x');
----------------------------------------------------------------------------------------------------------
 BatchExchange { order: [], dist: Single }
 └─BatchFilter { predicate: ((t.id > 10001:Int32) OR ((t.id = 10000:Int32) AND (t.name = 'x':Varchar))) }
   └─BatchScan { table: t, columns: [id, name] }
(3 rows)

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

No response

@github-actions github-actions bot added this to the release-2.2 milestone Nov 21, 2024
@Li0k Li0k self-assigned this Dec 5, 2024
@Li0k
Copy link
Contributor

Li0k commented Dec 16, 2024

After an offline discussion, this optimization can be achieved in two stages

  1. Split scan range, after transforming ScanRange into common range, the predicate which is not overlap can be split into multiple ScanRange and pushed to storage.

  2. Based on optimization 1, merge multiple ScanRanges to reduce the amount of scan data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants