-
Notifications
You must be signed in to change notification settings - Fork 175
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: optimise where clause filtering #2076
Conversation
Exciting! |
5f3005a
to
efe3613
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💪
def affected_shapes(%Filter{} = filter, %Relation{} = relation) do | ||
def affected_shapes(%Filter{} = filter, change) do | ||
shapes_affected_by_change(filter, change) | ||
rescue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? What kinds of errors do we expect to see here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super safety 😄 My reasoning is that if filtering crashes, all the shapes crash, so we need to be more careful than if this was shape specific code. There's a much more targeted rescue
in Table
that deals with record parsing errors which is much more likely to be hit. This one is more of a catch-all just to be extra safe.
Types of error it could catch:
Shape.is_affected_by_relation_change?
exceptions- change types the filter is not expecting are passed to
affected_shapes/2
These hopefully will never happen, but if they do, we'd rather the filter didn't crash.
assert Filter.affected_shapes(filter, change("t1", %{"id" => "7"})) == MapSet.new([7]) | ||
end) | ||
|
||
assert reductions < 500 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to see this specific number explain. What is the significance of it in this test? What should we do if this assertion fails?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Let me write a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job, exactly what I had in mind
✅ Deploy Preview for electric-next ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Fixes #2040 and is estimated to improve Trigger.dev's replication stream processing by 400x