简体   繁体   中英

Querying from azure db using linq takes a lot of time

I am using Azure db and my table has over 120000 records. Applied with paging of 10 records a page I am fetching data into IQueryable, but fetching 10 records only taking around 2 minutes. This query has no join and just 2 filters. While using Azure search I can get all the records within 3 seconds. Please suggest me who to minimise my Linq search as azure search is costly.

Based on the query in the comment to your question, it looks like you are reading the entire db table to the memory of your app. The data is potentially transferred from one side of the data centre to another, thus causing the performance issue.

unitofwork.Repository<EntityName().GetQueriable().ToList().Skip(1).Take(10);

Without seeing the rest of the code, I'm just guessing your LINQ query should be something like this:

unitofwork.Repository<EntityName().GetQueriable().Skip(1).Take(10).ToList();

Skip and Take should be executed on the db Server, while .ToList() is at the end will materialize the entities.

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