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

perf: query in-memory filtering as predicate [DHIS2-18041] #20094

Merged
merged 1 commit into from
Feb 26, 2025

Conversation

jbee
Copy link
Contributor

@jbee jbee commented Feb 26, 2025

Summary

Refactors the matching within the in-memory query engine to run the matching in 2 steps

  1. compute a Predicate matcher function for each Filter
  2. test each object candidate using the Predicate

This is an important performance improvement because...

  1. the 1st step which contains multiple lookups is only done once (as compared to before where is was done for each object candidate).
  2. the matching itself does not create temporary collections. The algorithm before the refactoring would matrix multiply nested paths with collections and then test each result. For example, a path like x.y.z with x and y being collections of size N and M would result in a intermediate collection of size N * M if z objects. These then each would be tested against the filter. This would happen for each object candidate tested. But building the intermediate collections is entirely unnecessary. The same can be done using "exists any" logic testing along the path instead. So in this example the code checks: exists and e in N where there exists any e in M where z matches the test.

Automatic Testing

There are countless tests directly and indirectly testing this. No new tests were added.

Manual Testing

Would be any sort of metadata API query using a filter: ?filter=...

@jbee jbee self-assigned this Feb 26, 2025
@jbee jbee merged commit 185f088 into master Feb 26, 2025
17 checks passed
@jbee jbee deleted the DHIS2-18041-in-mem-filter branch February 26, 2025 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants