dotnet / dotnet/efcore

Proposal: EF.Parameter(value).OptimizeFor(constantValue)

Open
#36,978 3 comments 2 reactions 0 assignees View on GitHub
area-query area-sqlserver customer-reported
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

### What problem are you trying to solve?

Sometimes SQL Server does not generate optimal query plans based on parameter sniffing alone.

By injecting a value for EF to generate a query hint for, we can give SQL Server a better chance to generate optimal queries.

### Describe the solution you'd like

Add the fluent api EF.Parameter(value).OptimizeFor(constantValue) which then adds

`Option(Optimize For \@p__linq__0 = 'constantValue')` into the command text.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.