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.
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?