简体   繁体   中英

NHibernate LINQ Parameter Sniffing issue

We are having performance issues due to parameter sniffing in SQL Server. Our application uses NHibernate with the LINQ provider.

I am searching for a way to add for example "OPTION(RECOMPILE)" to that certain SQL query. I now I could use interceptors for that, but I want it to be added only to certain IQueryable queries. So not on all my nhibernate queries, because then I would lose the advantages of query plan caching.

Other options to solve the parameter sniffing on 1 specific query with NHibernate are also welcome.

Use a query plan guide for it to specify an optimize for.

Here's a basic walkthrough: http://realsqlguy.com/dont-get-slimed-bad-parameter-sniffing/

Although this fixes it on the server side, so you'll need to find the query that is causing the issue, find the correct plan, and generate a plan guide for it. Maybe the next version of SQL Server will resolve some of the parameter sniffing issues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM