You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unless I'm mistaken, the OPTIMIZE FOR query hint in SQL Server is a query-level hint - appended at the end - rather than something specified on the placeholder within the SQL query; that makes sense as the parameter is sent only once, although it can be referenced multiple times in the SQL query.
As a result, this would already be covered by the general query hint issue #6717.
However, you would need to correlate the name of the parameter with the supplied constant value. From the C# end, I cannot see a better place to put this.
You're right that correlating the parameter name is problematic - though on the other hand expressing this on the parameter has the issue of allowing the user to specify different values for the same parameter (as I wrote above). But I agree what you propose is probably best.
I'll go ahead and open this for the backlog, let's see if other people vote for it.
Activity
roji commentedon Oct 15, 2025
Unless I'm mistaken, the
OPTIMIZE FORquery hint in SQL Server is a query-level hint - appended at the end - rather than something specified on the placeholder within the SQL query; that makes sense as the parameter is sent only once, although it can be referenced multiple times in the SQL query.As a result, this would already be covered by the general query hint issue #6717.
arontsang commentedon Oct 15, 2025
@roji it is a query level hint.
However, you would need to correlate the name of the parameter with the supplied constant value. From the C# end, I cannot see a better place to put this.
roji commentedon Oct 16, 2025
You're right that correlating the parameter name is problematic - though on the other hand expressing this on the parameter has the issue of allowing the user to specify different values for the same parameter (as I wrote above). But I agree what you propose is probably best.
I'll go ahead and open this for the backlog, let's see if other people vote for it.