MySQL BLOB 与文件存储小 PNG 图像?

发布于 2024-10-11 14:39:03 字数 69 浏览 1 评论 0原文

将大量小 PNG 图像(大部分小于 5KB)作为 BLOB 存储在数据库中是否更好,或者将它们作为图像文件存储在目录中更好?

Is it better practice to store a lot of small PNG images (<5KB mostly) in my database as BLOBs or would it be better to store them as image files in a directory?

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

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

发布评论

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

评论(2

诗笺 2024-10-18 14:39:04

这取决于对您来说更重要的是:速度还是访问的便利性。

如果您有一个应用程序,必须在概念上将图片绑定到记录(例如联系人应用程序),我会采用 dbms 方式。它可能没有那么快(一个非常主观的问题),但它更容易处理。

如果您想备份数据,将图片存储在 dbms 中也更简单! (考虑这样一个事实,您只需发出一个备份命令,并且您已经备份了所有数据)。

我怀疑你有办法存储与图片绑定的其他数据。如果这是真的,那么我肯定会选择 dbms 方式。如果这不应该是真的,那么就不要费心设计模式、创建数据库管理系统、创建连接、存储数据......太多的开销!

It depends on what is more important to you: speed or ease of access.

If you have an application in which you have to bind conceptually a picture to a record (eg. contacts application) I would go the dbms way. It may not be as fast (a very subjective matter), but it is much easier to handle.

It is also much simpler to store pictures in a dbms if you want to back up your data! (consider the fact you have to issue only ONE backup command and you have backed up ALL your data).

I suspect that you have a way to store other data which is bound to pictures. If this holds true then I would definitely go the dbms way. If this should not be true then don't bother designing a schema, creating the dbms, creating connections, storing data... to much overhead!

别挽留 2024-10-18 14:39:04

从性能的角度来看,从本地静态文件提供服务总是更快。除非绝对需要,否则不要访问数据库,建立连接和查询会产生大量开销。

From a performance standpoint, serving from local static files will always be faster. Don't go to the database unless you absolutely need to, there's a lot of overhead for making connections and queries.

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