Skip to content
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

Introduce context options to control constantization/parameterization of parameterized collections #34344

Closed
roji opened this issue Aug 3, 2024 · 0 comments · Fixed by #34406
Assignees
Labels
area-perf area-primitive-collections area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Milestone

Comments

@roji
Copy link
Member

roji commented Aug 3, 2024

Our current behavior parameterizes parameterized collections in SQL queries, typically via JSON. So Where(b => ids.Contains(b.Id) is translated on SQL Server via OPENJSON, and ids is encoded as a string parameter containing JSON array (done in #13617). However, although this allows having a single SQL query for different parameterized collections, it can lead to performance issues as the database isn't able to optimally plan for the query (see #32394).

To mitigate this, we are going to introduce context options for controlling the default mode: parameterized (e.g. OPENJSON) or expansion to constants; this would allow users to choose the default behavior that fits their needs. In addition, it will be possible to override this default on a per-collection basis via EF.Constant (#31552) and EF.Parameter (#34345).

Note: in the future we may also want to introduce a 3rd mode alongside parameterization and constantization: bucketized constantization. We should design the context option APIs here in a way which would allow for this in a nice and consistent way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-perf area-primitive-collections area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Projects
None yet
3 participants