[英]Get more than million rows from SQL Server table
In past I got System.OutOfMemoryException
during loading more than a million rows into a DataTable
from a SQL Server database.过去,我在将超过一百万行从 SQL 服务器数据库加载到DataTable
时遇到System.OutOfMemoryException
。 Is it true that instead of filling DataTable
, it is much faster eg to load it somehow to CSV
or any other format besides?确实不是填充DataTable
而是更快,例如以某种方式将其加载到CSV
或除此之外的任何其他格式? Please of your advice, eventually with given propose / example.请您提出建议,最终给出建议/示例。
Not knowing exactly how you might use the data, you could pull all the data using a SqlDataReader
and than write that to a SQLite database file.不确切知道如何使用数据,您可以使用SqlDataReader
提取所有数据,然后将其写入 SQLite 数据库文件。 This essentially gives you a local cached version of the million rows that you can query as if it were stored in the database, but doesn't take up memory since it's written to a local file (and provides in-memory cache if needed).这实质上为您提供了百万行的本地缓存版本,您可以像将其存储在数据库中一样查询它,但不会占用 memory,因为它已写入本地文件(并在需要时提供内存缓存)。
https://docs.microsoft.com/en-us/dotnet/standard/data/sqlite/?tabs=netcore-cli https://docs.microsoft.com/en-us/dotnet/standard/data/sqlite/?tabs=netcore-cli
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.