Do not add JOINs for Filters without a value #3703
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This potentially improves performance significantly with queries that use many filters on nested properties.
Please note that this change has been poorly tested and this PR must be considered more of a discussion than an actual mergable PR.
In our app we have an Doctrine Entity with multiple associated
ManyToOne
andManyToMany
Collections. We have also definedSearchFilter
s for properties of these Collections in the Annotation for this entity.While using the GraphQL API, we define the query with all these properties. When the user does not use the filter it will still be defined as
nestedPropertyName: []
. This causes theJOIN
to be added through (old) lines 83-84. However these JOINs serve no function (?) because (old) line 89 exits the function due to a lack of values.In our test joining all these relations even though they are not used makes a very significant performance difference (think 4000ms query vs 90ms in our specific case). Additionally these JOIN's filter out any results that do not have any items in that relation (even if the filter has no value), however I'm not sure that is a feature or a bug.
Regarding not setting the filter in the query in the first place: we aim to have our queries as static as possible only passing in different parameters, it seems that is already supported judging by (old) lines 88-90.
I would love to hear your opinion on this.