MySQL 中巨大 Blob 的处理?

发布于 2024-07-22 13:30:59 字数 449 浏览 1 评论 0原文

如何将巨大的 BLOB 插入 MySQL 数据库 (InnoDB)?

根据 MySQL 手册,LONGBLOB 类型的字段支持最大 4 GB 的数据大小。 但是如此庞大的数据是如何进入数据库的呢?

我尝试使用

INSERT INTO table (bindata) VALUES ( LOAD_FILE('c:/tmp/hugefile') );

如果巨大文件的大小大于大约 500 MB, 它会失败。 我已将 max_allowed_pa​​cket 设置为适当的大小; innodb_buffer_pool_size 的值似乎没有影响。

我的服务器计算机运行 Windows Server 2003,并具有 2 GB RAM。 我正在使用 MySQL 5.0.74-enterprise-nt。

How can I insert huge BLOBs into a MySQL database (InnoDB)?

Fields of type LONGBLOB support data sizes of up to 4 GB according to the MySQL manual. But how does data of such a huge size get into the database?

I tried to use

INSERT INTO table (bindata) VALUES ( LOAD_FILE('c:/tmp/hugefile') );

which fails if the size of hugefile is bigger than about 500 MB. I have set max_allowed_packet to an appropriate size; the value of innodb_buffer_pool_size doesn't seem to have an influence.

My server machine runs Windows Server 2003 and has 2 GB RAM. I'm using MySQL 5.0.74-enterprise-nt.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

伴我老 2024-07-29 13:30:59

BLOB 缓存在内存中,这就是为什么当您将 BLOB 插入数据库时​​,您将拥有 BLOB 的 3 个副本。

您的 500 MB BLOB 占用了 RAM 中的 1,500 MB,这似乎达到了您的内存限制。

BLOBs are cached in memory, that's why you will have 3 copies of a BLOB as you are inserting it into a database.

Your 500 MB BLOB occupies 1,500 MB in RAM, which seems to hit your memory limit.

生来就爱笑 2024-07-29 13:30:59

我不知道你使用哪个客户端/api,但是当尝试使用来自自己的 Java 和 Objective-C 客户端的 blob 时,MySQL 似乎并不真正支持 blob 流。 您需要足够的内存来多次将整个 blob 作为字节数组保存在 ram(服务器和客户端)中! 迁移到 64 位 Linux 会有所帮助,但不是理想的解决方案。

MySQL 不是为 BLOB 处理而设计的(对于小 BLOB 来说还可以:-)。 它占用“BLOB”中存储/读取内存的两倍或三倍。

抱歉,您必须使用其他数据库(例如 PostgreSQL)才能获得真正的 BLOB 支持。

I do not know which client/api you use, but when trying to use blobs from own Java and Objective-C clients it seems, MySQL does not really support streaming of blobs. You need enough memory to hold the whole blob as byte array in ram (server and client side) more than once! Moving to a 64 bit linux helps, but is not desired solution.

MySQL is not made for BLOB handling (ok for small BLOBs :-). It occupies twice or three times the ram to be stored/read in the "BLOB".

You have to use another database like PostgreSQL to get real BLOB support, sorry.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文