简体   繁体   中英

Linq to object Performance issue?

I have 10 millions of records in my table. I'm trying to fetch records by using linq query, but this cause performance issue. How can I fetch data without any delay or any performance issue?

You can use Enumerable.Skip and Enumerable.Take to implement paging for getting data using LINQ. For faster access you may re-visit your current indexes (if you have any) , on data and try loading only required data/columns.

You may see: Effective Paging Using Linq (Sample Code) - Code Project

If you are only going to search for records in the database and select only few of them and you are worried about performance then it would depend more on your database server. LINQ query against a data source translates into under laying query language. If your under laying data source is SQL Server then LINQ gets translated into SQL. You can get the generated SQL via LINQPad or Visual studio and see if it needs optimization by looking at it query execution plan . You may also setup indices against the column you want to search in your LINQ query, that will greatly improve records selection from 10 million rows.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM