-
Notifications
You must be signed in to change notification settings - Fork 25
Feature/inline multivariable filters #1182
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
base: main
Are you sure you want to change the base?
Conversation
This name better matches the intent of the function. This operates on a pre-parsed fql data structure, so it better contrasts with the node-map pattern concept.
This will later support inline filtering of multi-variable filter patterns.
|
The optimizer tests :exists, :not-exists, and :minus as if they bind vars that escape to the outer solution, so it could incorrectly push a pending top-level filter into those clauses based on “inner bindings”. -- the following test will fail which demonstrate this. Here is a sample query: Assume DB has at least one user with :schema/age > 45 (e.g. Brian=50), and also users with age ≤ 45 (Alice=42, Cam=34).
This can be fixed by not counting bindings inside :exists/:not-exists/:minus as guaranteed outer bindings. Filter pushdown rules should, I think, should be:
I think adding pattern bindings for exists, not-exists and minus to return #{} in optimize.cljc and then apply the pushdown rules above will work. |
bplatz
left 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.
Looks good other than the minus, et.c issues I brought up...
This patch extends the existing in-line filter optimization for single variable filter functions to multi-variable functions. It also introduces a clause-oriented query reordering flow.
Filters are separated from binding patterns at the beginning of the optimization step, the binding patterns are then reordered, and then both single- and multi- variable filters are inlined onto the sorted binding patterns when safe. The same separation, reordering, and inlining now occur within nested clauses, improving performance while preserving correctness and determinism.
Filters are inlined onto the sorted list of binding patterns at the point when exactly one referenced variable becomes newly bound by a pattern, and all other referenced variables were bound by a previous pattern. Filters that reference multiple variables and would have more than one newly bound in the same pattern are not inlined; they are emitted immediately after that pattern as a (not inline)
:filterpattern.