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

Comparing expressions can be slow #34149

Open
ranma42 opened this issue Jul 3, 2024 · 3 comments
Open

Comparing expressions can be slow #34149

ranma42 opened this issue Jul 3, 2024 · 3 comments

Comments

@ranma42
Copy link
Contributor

ranma42 commented Jul 3, 2024

In the query pipeline sometimes expressions are compared for (deep) equality.
This currently is based on a recursive visit of the subtree, which can be very costly if done multiple times while visiting the expression (it is quite easy to construct expression trees that require O(n^2) operations when visited).

This could be improved by computing a hash that filters out most of the inequalities as suggested in #34133 (comment)

@ranma42
Copy link
Contributor Author

ranma42 commented Jul 3, 2024

Side note: another case that could be interesting is the negation of an expression. Having it "ready to use" would make some predicate-related optimizations faster/cheaper.

@roji roji added this to the Backlog milestone Jul 3, 2024
@roji
Copy link
Member

roji commented Jul 3, 2024

Blocked on making our entire SqlExpression tree immutable (#32927); SelectExpression is currently mutable, and since it can be contained inside most SqlExpressions (thanks @ranma42), we can't cache the hashcode.

@roji
Copy link
Member

roji commented Jul 4, 2024

Blocked on making our entire SqlExpression tree immutable (#32927); SelectExpression is currently mutable, and since it can be contained inside most SqlExpressions (#34133 (comment)), we can't cache the hashcode.

Though on second thought, SelectExpression should never be mutable when it's already composed upon...

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