[英]Querying from azure db using linq takes a lot of time
I am using Azure db and my table has over 120000 records. 我正在使用Azure db,并且我的表有超过120000条记录。 Applied with paging of 10 records a page I am fetching data into IQueryable, but fetching 10 records only taking around 2 minutes. 应用10条记录分页时,我正在将数据读取到IQueryable中,但是要提取10条记录仅需2分钟左右。 This query has no join and just 2 filters. 该查询没有联接,只有2个过滤器。 While using Azure search I can get all the records within 3 seconds. 使用Azure搜索时,我可以在3秒内获得所有记录。 Please suggest me who to minimise my Linq search as azure search is costly. 请提出建议,建议谁减少我的Linq搜索,因为天蓝色搜索的成本很高。
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: 没有看到其余的代码,我只是猜测您的LINQ查询应该是这样的:
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. 跳过和获取应在db服务器上执行,而.ToList()最后将实现实体。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.