我的数据库中有200万条记录? [英] I have 2 million record in my database?

查看:170
本文介绍了我的数据库中有200万条记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据库中有200万条记录,这是从数据库中检索数据的最佳技术?



SQLReader或SQlDataAdapter



我尝试了什么:



i在我的数据库中有200万条记录,这是从数据库中检索数据的最佳技术?



SQLReader或SQlDataAdapter

i have 2 million record in my database which is best technique to retrieve data from databased?

SQLReader or SQlDataAdapter

What I have tried:

i have 2 million record in my database which is best technique to retrieve data from databased?

SQLReader or SQlDataAdapter

推荐答案

基本上来说,都不是。

如果您一次检索2,000,000行,则需要时间。即使每行是一列,10个字符宽,你也可以传输20,000,000个字节(没有他们需要的所有包装)来获取数据。

它真的都取决于什么你想要用它来做:DataAdapter获取所有行并且在它们全部被检索之前不返回,DataReader立即返回,但是每次请求新行时都会往返服务器(事实上,它没有,因为内置了一定程度的缓冲,但对于那些行也可以。这扩散了检索时间,并且可以使用户觉得它更快,因为延迟是在每行中摊销而不是在开始时大量的时间。

但是。 ..如果您要向用户提供此数据,那么您根本不想这样做!世界上没有一个控件可以很好地处理那么多数据,并且世界上没有一个用户想要一次性查看那么多数据!
Basically speaking, neither of them.
If you are retrieving 2,000,000 rows at once, it's going to take time. Even if each row is a single column, 10 characters wide, you would be transferring 20,000,000 bytes (without all the packaging they would need) just to fetch the data.
It's really all going to depend on what you want to do with it: a DataAdapter fetches all rows and does not return until they are all retrieved, a DataReader returns immediately, but makes a round trip to the server each time you request a new row (in fact, it doesn't, because there is a degree of buffering built in, but for that number of rows it might as well). That "spreads out" the retrieval time and can make it appear to a user that it's quicker, because the delay is amortised across each row instead of being a large dollop of time at the beginning.
But...if you are presenting this data to a user then you don't want to do that at all! There isn't a control in the world that will cope with that much data nicely, and there isn't a user in the world that wants to look at that much data in one lump!


这篇关于我的数据库中有200万条记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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