系统OutOfMemory异常 [英] System OutOfMemory Exception

查看:105
本文介绍了系统OutOfMemory异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我在Mysql上检索500万条记录时一直收到OutOfMemory Excemption

是否有可能在Mysql上检索数百万条记录?

Hi I keep receiving OutOfMemory Excemption when retrieving 5millions of record on my Mysql
is their any possible way to retrieve Millions of Record on Mysql ?

Using con As New MySqlConnection(conStr)
    con.Open()
    xTrans = con.BeginTransaction
    Using cmd As New MySqlCommand("LIMIT", con, xTrans)
        cmd.Parameters.AddWithValue("@LimitFromTo", LIMIT)
        cmd.CommandType = CommandType.StoredProcedure
        cmd.Prepare()
        Using conDap As New MySqlDataAdapter(cmd)
            conDap.Fill(ds)
        End Using
    End Using
    xTrans.Commit()
    con.Close()
End Using

推荐答案

我建​​议您考虑使用MySqlDataReader并依次处理每个记录,而不是使用DataSet并填充它。填充数据集时,所有记录都会同时被提取,这可能会占用大量内存 - 读者不会这样做:它会在您需要时一次返回一个。由于用户无法找到他想要的任何内容,因此尝试一次显示5,000,000条记录将是一件荒谬的事情,所以不应该给您带来太大的不便。
Instead of using a DataSet and filling it, I would suggest that you consider a MySqlDataReader and process each record in turn. When you fill a dataset, all the records are fetched at the same time, which could use spectacular amounts of memory - A reader doesn''t do that: it returns them one at a time as you demand them. Since trying to display 5,000,000 records at once would be a ridiculous thing to do as the user would be unable to find anything he wanted, it shouldn''t inconvenience you too much.


http://stackoverflow.com/questions/13648523/how-to-import-large-sql-file-using-mysql-exe-through-streamreader-standardinp [ ^ ]



浏览本网站。
http://stackoverflow.com/questions/13648523/how-to-import-large-sql-file-using-mysql-exe-through-streamreader-standardinp[^]

Have a look in this website.


这篇关于系统OutOfMemory异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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