-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Bucketization for IN #36370
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
Bucketization for IN #36370
Conversation
082b50e
to
d419b79
Compare
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.
Pull Request Overview
This PR implements bucketization for IN
-clause parameters to pad parameter lists to fixed sizes, reducing plan cache bloat, and updates tests to expect the new padded parameter counts.
- Introduces bucketization logic in
SqlNullabilityProcessor
and aParametersPadFactor
strategy - Adds a helper
ExpandParameterIfNeeded
to consolidate parameter expansion code - Defines
MaxParameterCount
constant inSqlServerSqlNullabilityProcessor
and updates the over-limit check - Updates/extends provider-specific functional tests to assert on the padded parameter lists
- Adds a new relational baseline test for
Parameter_collection_Contains_parameter_bucketization
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/EFCore.Relational/Query/SqlNullabilityProcessor.cs | Added bucketization code, ParametersPadFactor , and ExpandParameterIfNeeded |
src/EFCore.SqlServer/Query/Internal/SqlServerSqlNullabilityProcessor.cs | Introduced MaxParameterCount constant and replaced hardcoded threshold |
test/EFCore.Relational.Specification.Tests/Query/NonSharedPrimitiveCollectionsQueryRelationalTestBase.cs | Added new Parameter_collection_Contains_parameter_bucketization test |
test/EFCore.Sqlite.FunctionalTests/Query/NonSharedPrimitiveCollectionsQuerySqliteTest.cs | Updated expected SQL for padded parameters in SQLite tests |
test/EFCore.SqlServer.FunctionalTests/Query/NonSharedPrimitiveCollectionsQuerySqlServerTest.cs | Updated expected SQL for padded parameters in SQL Server tests |
test/EFCore.Sqlite.FunctionalTests/... (GearsOfWarQuerySqliteTest.cs) | Adjusted IN lists to include padded parameters |
test/EFCore.SqlServer.FunctionalTests/... (GearsOfWarQuerySqlServerTest.cs, etc.) | Adjusted IN lists to include padded parameters |
test/EFCore.SqlServer.FunctionalTests/... (Northwind*QuerySqlServerTest.cs) | Adjusted IN lists to include padded parameters |
test/EFCore.SqlServer.FunctionalTests/Query/AdHocMiscellaneousQuerySqlServerTest.cs | Updated a multi-IN clause to include padded date-time parameters |
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.
Looks pretty straightforward and good! See some suggestions and one possible bug.
@@ -857,6 +846,38 @@ InExpression ProcessInExpressionValues( | |||
throw new UnreachableException(); | |||
} | |||
} | |||
|
|||
// Bucketization is a process used to group parameters into "buckets" of a fixed size when generating parameterized collections. |
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.
That's... substantial :)
@@ -280,6 +282,19 @@ protected override SqlExpression VisitIn(InExpression inExpression, bool allowOp | |||
} | |||
} | |||
|
|||
/// <inheritdoc /> | |||
protected override int CalculateParameterBucketSize(int count, RelationalTypeMapping elementTypeMapping) | |||
=> count switch |
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.
- Is there any particular reason why the conditions of this
switch
differ from those in the same-named method insrc/EFCore.Relational/Query/SqlNullabilityProcessor.cs
? - If the answer to the previous question is "no", can/should the two methods be consolidated into an abstraction that can be injected and used in both cases?
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.
NVM ignore me, this is the MSSQL-specific implementation.
Closes #36364.