-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Global query filters produce too many parameters #24476
Comments
This should be easy to fix if we de-dupe runtime parameters we add from query filter |
That sounds promising. I raised this as an enhancement but I wonder if it straddles the line with bug and whether you might consider for servicing in 3.1 and/or 5.0. If I were to make a case for it...
In any case, thanks for looking at it. |
The process for de-duping runtime parameters does not exist even for non-query filter parameters hence it is an enhancement and not a bug. Further risk of making this change is not minimal since it could break existing working query if something does not line up. We will discuss in a team this but it is unlikely that it meets patch bar. |
* Don't duplicate query filter parameters Fixes #24476 --------- Co-authored-by: Steven.Darby <Steven.Darby@tribalgroup.com>
If I add global query filters to all of my entities and the filters use the same property on the DbContext as a value for filtering in all of them, the property is parameterised separately for each entity type in a query rather than sharing one parameter with a common value.
A large number of parameters can make query optimisation harder for the database provider.
In the example below I have two similar DbContexts but with different filtering methods, and use them to run a similar query that includes 3 entities.
One applies a TenantId filter using global query filters: this produces 3 parameters, all with the same value.
The other applies the TenantId filter manually in the Includes and in the Where condition: this produces just 1 parameter. I would hope that you can optimise the global query filters to use a similar strategy to this.
In production we have queries spanning 30+ entities and thus 30+ parameters.
Output:
The text was updated successfully, but these errors were encountered: