[3.0] Perf: Skip visiting table inside ColumnExpression #17651
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.
Description
An algorithmic issue in the 3.0 query code can cause execution time to grow quadratically with increasing number of includes and entity properties. This can make queries both compile and execute much slower in some scenarios.
Customer Impact
Some queries with many
Include
calls could be so slow that they appear to hang.How found
Customer reported.
Test coverage
We don't currently have perf testing for queries of this level of complexity. Perf testing is something we are already actively working on.
See below for local perf numbers before and after the change--in this case we're going from 175 seconds to 19 milliseconds.
Regression?
Yes, regression in perf from 2.2.
Risk
We have spent some time deciding what to do now and going forward. For now, we have a low-risk fix that is not 100% architecturally correct, but which fixes the issue in a safe way for the current code. (The current code only uses
SelectExpression
in certain ways, for which this fix is correct.) We are planning to follow up in 3.1 with a more architecturally sound solution.Resolves #17455
5 levels of collection include and 1 reference include. Each class containing 5 properties (+ 1 for shadow prop as needed for FK).
No data on server side. (no shaper code executed)
Run includes time to compile the query and execute it against the server.
On preview9 package
After the fix