如何从EF表中选择300万条记录? [英] How to select 3 million record from table with EF?

查看:141
本文介绍了如何从EF表中选择300万条记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨...

我有一张包含300万条记录的桌子。

我想要的时候选择显示错误



EntityFramework.dll中发生了'System.OutOfMemoryException'类型的未处理异常



为什么...... ??

我会如果有人可以提供帮助,请感激不尽。



我的尝试:



Hi ...
I have a table with 3 million records.
when I want Select Show Error

An unhandled exception of type 'System.OutOfMemoryException' occurred in EntityFramework.dll

Why ..??
I will be grateful if anyone can help.

What I have tried:

Hi ...
I have a table with 3 million records.
when I want Select Show Error

An unhandled exception of type 'System.OutOfMemoryException' occurred in EntityFramework.dll

Why ..??
I will be grateful if anyone can help.

推荐答案

考虑一下你想要做什么。 300,000行任意大量的字符非常非常快速地增加了大量内存。如果你有两列,每个100个字符长,那么你正在尝试检索至少3,000,000 * 200字节:600兆字节,没有任何包装(其中有很多)。如果每行包含一个员工的小缩略图,那么您可以立即获得几千兆字节!尝试一次性检索那么多信息是否合理?不 - 因为你甚至无法快速处理它,更不用说它给用户了!

这就像购买你今天一生都需要的所有面包因为价格将在下周上升。你可以省钱,但你必须找一个备用的房子存放,保持害虫,预先找到钱等等。



所以理查德和NPC已经说过了:甚至不想一次性获取那么多内容:分页,搜索它,只返回你实际需要的列以及只需要你需要的行:但是不要试图一次性取出它们go!
Think about what you are trying to do for a moment. 3,000,000 rows of any significant number of characters adds up to a huge amount of memory very, very quickly. If you have two columns, each 100 characters long, then you are trying to retrieve a bare minimum of 3,000,000 * 200 bytes: 600 megabytes without any packaging (of which there is a lot). If each row contained a small thumbnail picture of an employee then you could get to a couple of gigabytes in no time! Is it at all reasonable to try and retrieve that much info in one go? No - because you can't even process it that fast, much less display it to the user!
That's like buying all the loafs of bread you are going to need for your whole life today because the price will rise next week. You may save money, but you have to find a spare house to store it in, keep vermin away, find the money up front, etc.

So as Richard and NPC have said: don't even think of fetching that much in one go: page it, search it, return only the columns you actually need as well as only the rows you need: but don't try to fetch it all in one go!


Quote:

EntityFramework.dll中发生未处理的System.OutOfMemoryException类型异常

为什么.. ??

An unhandled exception of type 'System.OutOfMemoryException' occurred in EntityFramework.dll
Why ..??



问题很明显:没有足够的内存来处理3,000,000条记录。



想想这种情况:你有3,000,000条记录,一次性取出它们并将它们转移到网格中对你来说很简单,但对于用户来说,一个3,000,000条记录的网格是否实用?

从服务器获取记录需要多长时间?构建网格需要多长时间?



如果您有一个具有3,000,000行的网格示例,这是对用户的最佳呈现和最佳平均值查找数据,请分享。



您必须考虑其他方式来显示数据。

如何处理黄页(电话号码) ) 在你的国家 ? 1个单一网格,您可以浏览数百万条记录吗?


Problem is obvious: there is not enough memory to handle 3,000,000 records.

Think about the situation: you have 3,000,000 records, fetch them in 1 go and dump them in a grid is simple for you, but a grid of 3,000,000 records is it practical for the user ?
how long does it take to get the records from the server ? how long does it take to build the grid ?

If you have a single example of a grid with 3,000,000 rows that is the best presentation to the user and best mean of finding data, please share.

You have to think of other ways to show the data.
How is working yellow pages (telephone numbers) in your country ? 1 single grid and you browse millions of records ?


这篇关于如何从EF表中选择300万条记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆