Repository navigation
Bucketization for IN - #36370
Merged
Merged
Bucketization for IN#36370
Conversation
cincuranet
force-pushed
the
buckets
branch
4 times, most recently
from
July 15, 2025 09:10
082b50e to
d419b79
Compare
cincuranet
marked this pull request as ready for review
July 15, 2025 10:01
Contributor
There was a problem hiding this comment.
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
SqlNullabilityProcessorand aParametersPadFactorstrategy - Adds a helper
ExpandParameterIfNeededto consolidate parameter expansion code - Defines
MaxParameterCountconstant inSqlServerSqlNullabilityProcessorand 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 |
roji
requested changes
Jul 21, 2025
roji
left a comment
Member
There was a problem hiding this comment.
Looks pretty straightforward and good! See some suggestions and one possible bug.
roji
reviewed
Jul 28, 2025
| } | ||
| } | ||
|
|
||
| // Bucketization is a process used to group parameters into "buckets" of a fixed size when generating parameterized collections. |
roji
approved these changes
Jul 28, 2025
IanKemp
reviewed
Jul 28, 2025
|
|
||
| /// <inheritdoc /> | ||
| protected override int CalculateParameterBucketSize(int count, RelationalTypeMapping elementTypeMapping) | ||
| => count switch |
There was a problem hiding this comment.
- Is there any particular reason why the conditions of this
switchdiffer 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.
NVM ignore me, this is the MSSQL-specific implementation.
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.
Closes #36364.