简体   繁体   English

使用linq从Azure DB查询需要很多时间

[英]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.

相关问题 通用列表上的Linq需要很多时间 - Linq on generic List takes a lot of time 使用谓词进行过滤需要花费大量时间 - Filter using a predicate takes a lot of time 将列表(从mysql数据库获取)转换为数据帧需要花费大量时间 - Conversion of list(fetched from mysql database) to dataframe takes lot of time 对List进行排序需要花费大量时间 - Sorting a List takes a lot of time 读取Excel单元格需要大量时间 - Reading Excel cells takes a lot of time Android应用需要大量时间才能启动 - Android app takes lot of time to start 我的 Bootstrap 网站需要很长时间才能加载。 我使用了 Envato 的模板 Celia 来构建它 - My Bootstrap website takes a lot of time to load. I used template Celia from Envato to build it 从数据库获取连接的相同方法,但在visualvm中花费不同的时间 - same method to get connection from DB but takes different time in visualvm 使用LINQ to SQL查询SQL Azure中经常更改的列时如何提高性能 - How do I improve performance when querying on a column that changes frequently in SQL Azure using LINQ to SQL 使用应用程序BL将大量数据从同一数据库迁移到不同数据库的性能 - Performance in migrating a lot of data from the same DB to different DB using application BL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM