开发者

When I call Count method in Entity Framework, does it process all the columns or just one or what?

Im looking for otimization.

When I call Count method in Entity Framework, does it process all the columns or only开发者_高级运维 one or what?

If you also have any official site talking about this, I would appreciate.

Thank you.


I did some tests a while ago and found out that EF does a count on the server, it sends a query with a SELECT COUNT so it does not load all records for sure.

about the columns, if you are referring to the difference between COUNT(*) or COUNT(Id) or COUNT(1) I have read somewhere a while ago that for SQL Server there is no difference, the COUNT(*) is optimized as COUNT(1) anyway.

you could read many articles online or question here on SO... not excatly 100% what you asked but similar topics on performances of EF and ORM...

How to COUNT rows within EntityFramework without loading contents?

http://ayende.com/blog/4387/what-happens-behind-the-scenes-nhibernate-linq-to-sql-entity-framework-scenario-analysis

How to optimize Entity Framework Queries

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜