Skip to content

Support query-level SQL hints #838

@Vijay-Nirmal

Description

@Vijay-Nirmal

Feature request

Summary:
Add support for query-level SQL hints (such as OPTION clauses) that can be appended to generated queries, for example: OPTION (RECOMPILE), OPTION (MAXDOP 1).

Motivation:
Sometimes advanced performance tuning, query control, or SQL Server-specific operations require passing additional hints at the query statement level. At present, EntityFramework-Plus provides table-level hints but does not appear to expose a way to add arbitrary OPTION hints to the end of generated queries at the query level.

Proposal:

  • Allow users to specify custom SQL option hints via an WithQueryHint(...) extension or similar API that will inject the hint at the end of the SQL statement.
  • Example usage:
    dbContext.Entities.Where(...).WithQueryHint("RECOMPILE").ToList();

Typical use cases:

  • Forcing parameterized queries to recompile.
  • Limiting degree of parallelism with MAXDOP N.
  • Query-level hints required for advanced SQL Server tuning.

Notes:

  • Please let me know if Query Hints are already supported in some form that I may have overlooked.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions