实体框架中存储过程缓慢 [英] Stored procedure is slow in Entity Framework

查看:139
本文介绍了实体框架中存储过程缓慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从使用db中的sp的查询

I am calling a stored procedure (that returns data) from Entity Framework using the query below

from sp in db.GetSale(bID, SID,m,y).Where(x => x.isActive == true)
select sp

如果我直接运行这个过程,只需要2秒钟,但是当我通过EF调用这个存储过程时,需要10到15秒。

If I run this procedure directly, it takes only 2 seconds, but when I call this stored procedure through EF, it is taking 10 to 15 seconds.

任何指导来改善情况?我已经看到其他帖子在这里,但没有成功

Any guidance to improve the situation? I have seen other post here on SO but have no success

编辑

这是sqlplan为我的程序
https://skydrive.live.com/redir?resid=87DCBD5D3E9AAA57!374

Here is sqlplan for my procedure https://skydrive.live.com/redir?resid=87DCBD5D3E9AAA57!374

推荐答案

我怀疑参数嗅探。

尝试在程序中应用反参数嗅探代码。 (在使用它们之前,将参数分配给局部变量)

Try applying anti-parameter sniffing code in your procedure. (Assign parameters to local variables before using them).

http://blogs.technet.com/b/mdegre/archive/2012/03/19/what-is-parameter-sniffing.aspx

这篇关于实体框架中存储过程缓慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆