开发者

MySQL BLOB vs File for Storing Small PNG Images?

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?


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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜