linq是我的SQL服务器性能吗? [英] Is linq down my SQL server performance?

查看:73
本文介绍了linq是我的SQL服务器性能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几天前我改变了CRUD操作代码。实体框架SP到LINQ。

现在我能够看到频繁的sql server块。让我知道为什么?



是linq insert还是并发linq insert使我的数据库性能更好?



< b>我尝试了什么:



一旦基于性能的sql server利用率高或CRUD通过linq与并发用户有意义。我真的不明白

解决方案

如果没有令人信服的理由使用LINQ,那么如果它们有效,请返回SP。如果您编写了大量LINQ代码而没有考虑如何生成SQL,那么您运行的SQL将与SP非常不同,将会有大量不了解的表访问权限排序。



如果您要加入表格,请确保您没有使用延迟加载(谷歌实体框架延迟加载)。您还可以使用SQL事件探查器之类的工具来查看正在生成的SQL。



但是,在一天结束时,如果它们正常工作,只需返回SP。 LINQ的优点是不必自己编写很多SQL,但是你必须注意你要求EF生成SQL,这是一个超出论坛帖子范围的大问题。不要认为LINQ是一种灵丹妙药,可以提供更好的性能以及更简单的代码。


few days back i have changed the CRUD operations code . entity framework SP to LINQ.
now i can able to see frequent sql server block. let me know why?

is linq insert or concurrent linq insert make my Database performance?

What I have tried:

once the performance based sql server utilisation high or CRUD via linq with concurrent users its make sense. i really don't understand

解决方案

If there was no compelling reason to use LINQ then go back to SPs if they work. If you've written a whole bunch of LINQ code without any consideration as to how the SQL is generated then the SQL you're running will be very different from SPs, there will be lots of table access you don't know about and all sorts.

If you are joining tables then make sure you're not using "lazy loading" (google "entity framework lazy loading"). You can also use tools like SQL Profiler to see the SQL being generated.

At the end of the day though, just go back to SPs if they work. LINQ's advantages are around not having to write a lot of SQL yourself but you have to be mindful of how you're asking EF to generate the SQL, it's a big subject outside the scope of a forum post. Don't think LINQ is a panacea that gives you better performance etc as well as easier code.


这篇关于linq是我的SQL服务器性能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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