实体框架 context.SaveChanges() 缓慢 - 包括 SQL Profiler
我知道 EF 不太适合批量操作,但我试图了解我们遇到的问题。
我们正在循环一个文本文件,其中有 5,000 个产品要插入到我们的数据库中。
在调用 context.SaveChanges() 并观察探查器时,我看到:
Audit Login 0MS
RPC: Completed (theactual query to insert the products) Showing as 9 Reads and auration of 0 MS
Audit Logout 2750MS
Why审核注销是否需要 2 秒以上?实际的 SQL 查询根本不花任何时间,审核登录也不花任何时间。
这是EF的开销吗?有人有什么建议吗?我唯一偶然发现的是预先生成的视图,但不确定这是否有帮助。
I know EF isn't great for batch operations, but I am trying to understand an issue that we are having.
We are looping a text file, for which there are 5,000 products to be inserted in to our DB.
On calling context.SaveChanges() and watching the profiler I see:
Audit Login 0MS
RPC: Completed (the actual query to insert the product) Showing as 9 reads and a duration of 0 MS
Audit Logout 2750MS
Why is the audit log out taking 2+ seconds? The actual SQL query is not taking any time at all, neither is the audit login.
Is this the overhead of EF? Has anyone got any suggestions? The only thing I have stumbled upon is pre generated views, but not sure if that will help or not.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
注销本身并不需要 2 秒,分析器显示注销事件的会话持续时间,因此从登录到注销为 2750 毫秒。
在调用注销之前,应用程序中是否发生了一些可能需要一些时间的事情?插入和注销之间会发生什么?
The logout itself isn't taking 2 seconds, profiler shows the duration of the session on the logout event, so it was 2750ms from login to logout.
Is there something happening in the application before it calls the logout that could take some time? What happens between the time of the inserts and logout?