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

improvement: better disjoint where clause evaluation #2040

Closed
icehaunter opened this issue Nov 26, 2024 · 1 comment · Fixed by #2076
Closed

improvement: better disjoint where clause evaluation #2040

icehaunter opened this issue Nov 26, 2024 · 1 comment · Fixed by #2076
Assignees

Comments

@icehaunter
Copy link
Contributor

Right now, when Electric knows about N shapes with where clauses, we're quite naive about figuring out which shapes does a given transaction fall into. For example, if we have N shapes over the same table with where clauses in the pattern of WHERE id = $1.

We can improve the performance and reduce the CPU usage if we're smarter about it. For the example above, we can infer that if one of the where clauses is true, all the others are false and we don't need to evaluate them. Moreover, for = check, we can precompute a lookup structure to know in one lookup which where clauses of the set can evaluate to true at all. If where clauses have WHERE ID = $1 AND .... form, then we can cut away definitely-false where clauses and execute only M << N checks instead.

The precomute can be done on a relatively rare event of shape creation (rare in relation to transaction processing).

@balegas
Copy link
Contributor

balegas commented Nov 26, 2024

I'm not fan of early optimizations, but I'm interested in knowing the speed up when we have lots of shapes in that format, which seems it's going to be a frequent pattern.

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

Successfully merging a pull request may close this issue.

3 participants