Add MaxSingleQueryCollections - #16
Merged
Merged
Conversation
Counts the collections one SQL query loads, through collection Includes and collections in a projection, since each multiplies the rows returned for the others. A split query counts none. Log default of 1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds
MaxSingleQueryCollections, which limits how many collections one SQL query loads. A single query joins every collection it loads, so each multiplies the rows returned for the others: a cartesian explosion.Counts
IncludeandThenInclude, including string paths. A collection restated toThenIncludesomething below it counts once.Employees = _.Employees.ToList(), including collections nested in them.Does not count
_.Employees.Count()or.Any(), which is a subquery rather than a join.AsSplitQuery()orUseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery).AsSingleQuery()overrides a context that splits by default.It is measured while a query is compiled, like the other shape levels, and works with
WithQueryComplexity, the log and throw level validation, and the model cache key.Choices
MultipleCollectionIncludeWarning, which only coversIncludeand goes silent once a splitting behavior is configured. Existing users will see new log lines for queries with two collections. It only logs, so nothing breaks.LoggingTests.LogDefaultschanged accordingly.QueryComplexityLimitsconstructor, with a default ofnull. Existing source compiles unchanged, but assemblies built against the old constructor need a recompile.Known gaps
Selectprojections are inspected, notGroupByresult selectors orSelectMany.OwnsManycollections, which are stored in their own table, are not treated differently.