简体   繁体   English

C#数据集,分页和大量数据

[英]C# Datasets, paging and large amounts of data

I want to show a large amount of data in a dataset, 100,000 records approx 10 columns, this consumes a large amount of ram 700MB. 我想在数据集中显示大量数据,100,000条记录大约10列,这消耗了700MB的大量内存。 I have also tried using paging which reduces this by about 15-20% but I don't really like the Previous/Next buttons involved when using paging. 我也试过使用分页,这减少了大约15-20%,但我不喜欢使用分页时涉及的上一个/下一个按钮。 I'm not writing the data to disk at present, should I be? 我现在不是把数据写到磁盘上,我应该吗? If so what is the most common method? 如果是这样,最常见的方法是什么? The data isn't to be stored forever just whilst it is being viewed, then a new query may be run and a nother 70,000 records could be viewed. 在查看数据时,数据不会永久存储,然后可以运行新查询,并且可以查看其他70,000条记录。 What is the best way to proceed? 什么是最好的方法?

Thanks for the advice. 感谢您的建议。

The reality is that the end-user rarely needs to see the totality of their dataset, so I would use which method you like for presenting the data (listview) and build a custom pager so that the dataset is only fed with the results of the number of records desired. 实际情况是最终用户很少需要查看其数据集的总体情况,因此我会使用您喜欢的方法来呈现数据(listview)并构建自定义分页器,以便数据集仅提供结果所需的记录数量。 Otherwise, each page load would result in re-calling the dataset. 否则,每次页面加载都会导致重新调用数据集。

The XML method to a temp file or utilizing a temp table created through a stored proc are alternatives but you still must sift and present the data. 临时文件的XML方法或利用通过存储过程创建的临时表是替代方案,但您仍然必须筛选和显示数据。

An important question is where this data comes from. 一个重要的问题是这些数据来自何处。 That will help determine what options are available to you. 这将有助于确定您可以使用哪些选项。 Writing to disk would work, but it probably isn't the best choice, for three reasons: 写入磁盘可行,但它可能不是最佳选择,原因有三:

  1. As a user, I'd be pretty annoyed if your app suddenly chewed up 700Mb of disk space with no warning at all. 作为一个用户,如果您的应用程序突然咀嚼了700Mb的磁盘空间而没有任何警告,我会非常恼火。 But, then, I'd notice such things. 但是,那时,我会注意到这些事情。 I suppose a lot of users wouldn't. 我想很多用户都不会。 Still: it's a lot of space. 仍然:这是一个很大的空间。
  2. Depending on the source of the data, even the initial transfer could take longer than your really want to allow. 根据数据来源,即使初始传输也可能需要比您真正想要的更长的时间。
  3. Again, as a user, there's NO WAY I'm manually digging through 700Mb worth of data. 同样,作为用户,我没有办法手动挖掘700Mb的数据。 That means you almost certainly never need to show it. 这意味着你几乎肯定不需要展示它。 You want to only load the requested page, one (or a couple) pages at a time. 您只想一次加载所请求的页面,一个(或几个)页面。

我会建议内存映射文件......不确定.NET是否包含对它的支持。

That is a lot of data to be working with and keeping aroudn in memory. 这是很多数据要处理并将aroudn保留在内存中。

Is this a ASP.NET app? 这是一个ASP.NET应用程序吗? Or a Windows app? 还是Windows应用程序?

I personally have found that going with a custom pager setup (to control, next previous links) and paging at the database level to be the only possible way to get the best performance, only get the data needed.... 我个人已经发现,使用自定义寻呼机设置(控制,下一个上一个链接)和数据库级别的分页是唯一可能获得最佳性能的方法,只获得所需的数据....

如果要减少内存占用,请在SQL中实现分页

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM