Pregenerate SQL for precompiled queries#33510
Conversation
dd2bc53 to
d53215a
Compare
| /// </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.
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.
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.
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