优化数据库中的 MySQL 文件(blob)
由于内部原因(框架结构),我将许多图像保存在带有mediumBLOB的表中。
考虑到检索这些图像的查询是以相当低的速率发送的,有没有办法告诉 mysql 将此表从内存中删除?我不想让一个 2GB 内存的表只偶尔使用一次。
有什么办法可以优化这个吗?
(注意:如果这有帮助,我可以将该表移动到仅包含该表的新数据库中)
谢谢
due to internal reasons (framework structure) I save many images in a table with a mediumBLOB.
Considering the query to retrive these images are sent with a pretty low rate is there a way to tell mysql to keep off this table from memory? I don't want to have a table of 2GBs in memory used only once in a while.
Are there any way to optimize this?
(Note: if this helps I can move this table in a new database containing only this table)
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
MySQL不会为BLOB类型生成内存表,因为存储引擎不支持它。
http://dev.mysql.com/doc/refman /5.0/en/internal-temporary-tables.html
“某些情况会阻止使用内存中的临时表,在这种情况下,服务器会使用磁盘上的表:
这意味着您应该将 BLOB 放入不同的表中,并将其他有用的数据保留在 BLOBless 表中,以便优化表。
MySQL won't generate in-memory table for BLOB types, as the storage engine doesn't support it.
http://dev.mysql.com/doc/refman/5.0/en/internal-temporary-tables.html
"Some conditions prevent the use of an in-memory temporary table, in which case the server uses an on-disk table instead:
Which means you should put the BLOB into a different table, and leave other useful data in a BLOBless table so that table will be optimized.
对我来说,将此类表移动到单独的数据库中听起来是一种完全有效的方法。在工作中,我们有一台数据库服务器用于操作内容(订单、目录等),另一台数据库服务器用于日志(网络日志和电子邮件副本)和媒体(图像、视频和其他二进制文件)。即使在同一台机器上运行单独的实例也是值得的,因为正如您所提到的,它对缓冲区缓存(或任何您的存储引擎的等效项)进行了分区。
Moving that sort of table into a separate database sounds like a perfectly valid approach to me. At work we have one database server for our operational content (orders, catalogue etc) and one for logs (web logs and copies of emails) and media (images, videos and other binaries). Even running separate instances on the same machine can be worthwhile since, as you mentioned, it partitions the buffer cache (or whatever your storage engine's equivalent is).