-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Pregenerate SQL for precompiled queries #33510
Conversation
dd2bc53
to
d53215a
Compare
@@ -41,15 +43,16 @@ public class RelationalQueryCompilationContextFactory : IQueryCompilationContext | |||
/// any release. You should only use it directly in your code with extreme caution and knowing that | |||
/// doing so can result in application failures when updating to a new Entity Framework Core release. | |||
/// </summary> | |||
public virtual QueryCompilationContext Create(bool async, bool precompiling) | |||
=> new RelationalQueryCompilationContext(Dependencies, RelationalDependencies, async, precompiling); | |||
public virtual QueryCompilationContext Create(bool async) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this PR introduces the new CreatePrecompiled() variant below (which accepts the new nonNullableReferenceTypeParameters), this reverts the previous change (this is also good because it leaves precompilation out of non-experimental public APIs).
/// <param name="dependencies">Parameter object containing dependencies for this class.</param> | ||
/// <param name="relationalDependencies">Parameter object containing relational dependencies for this class.</param> | ||
/// <param name="async">A bool value indicating whether it is for async query.</param> | ||
public RelationalQueryCompilationContext( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, this reverts the earlier change and we have separation between the existing public APIs (which are precompilation-unaware) and new, experimental APIs for precompilation.
|
||
static object GenerateNonNullParameterValue(Type type) | ||
{ | ||
// In general, the (2nd part of) the query pipeline doesn't care about actual values - it mostly looks a null vs. non-null. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The alternative approach here would be to just put an object
instance, and to allow the 2nd part of the query pipeline to throw if it attempts to cast it (e.g. to a collection); we'd simply catch exceptions and assume we can't pregenerate in that case.
@dotnet/efteam rebased this on latest main, should be ready for reviewing. |
When generating the shaper for a precompiled query, we now check the number of nullable parameters it has, and if that number is low (currently 3), we pregenerate SQLs (or rather, RelationCommands) for it. This PR is stacked on top of #33297 (review only the last commits).
Implementation overview:
Closes #29753