score:3

Accepted answer

See http://msdn.microsoft.com/en-us/library/bb357513.aspx#1

Skip method is very useful with LINQ to SQL to organize server-side results paging, and some more things. But there are performance issues in some cases, because LINQ can build too difficult SQL queries from specified LINQ expressions. I touched this problem with MS SQL Server 2008. (...)

(...) if there are 1000000 records in the Orgs table this query will be executed very long time because DB server will sort records in memory (unlikely you have an appropriate index with all columns ordering). And even so simple query

orgs.Skip(10).Count() requires a significant amount of time, while

orgs.Count()-10 performes much more quickly :)

Perhaps that's the root of the problem.


Related Articles