Entity Framework 4.2 exec sp_executesql does not use indexes (parameter sniffing)

后端 未结 2 787
感动是毒
感动是毒 2020-11-28 13:38

I\'m encountering some major performance problems with simple SQL queries generated by the Entity Framework (4.2) running against SQL Server 2008 R2. In some situations (but

2条回答
  •  爱一瞬间的悲伤
    2020-11-28 13:51

    At this point I would recommend:


    Set the optimize for ad hoc workloads setting to true.

    EXEC sp_configure 'show advanced', 1;
    GO
    RECONFIGURE WITH OVERRIDE;
    GO
    EXEC sp_configure 'optimize for ad hoc', 1;
    GO
    RECONFIGURE WITH OVERRIDE
    GO
    EXEC sp_configure 'show advanced', 0;
    GO
    RECONFIGURE WITH OVERRIDE;
    GO
    

    If after some time this setting doesn't seem to have helped, only then would I try the additional support of the trace flag. These are usually reserved as a last resort. Set the trace flag using the command line via SQL Server Configuration Manager, as opposed to in a query window and using the global flag. See http://msdn.microsoft.com/en-us/library/ms187329.aspx

提交回复
热议问题