MySQL BLOB vs File for Storing Small PNG Images?

前端 未结 2 1777
谎友^
谎友^ 2020-12-21 18:17

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?

相关标签:
2条回答
  • 2020-12-21 18:37

    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 讨论(0)
  • 2020-12-21 18:49

    It depends on what is more important to you: speed, 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 be not that fast (something which is very subjective) but it is much easier to handle.

    It is also much simpler to store pics 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 somehow to store other data which is bound to pictures. If this holds true than i would definitely go the dbms way. If this should not be true than don't bother designing a schema, create the dbms, create connections, store data,.... to much overhead!

    0 讨论(0)
提交回复
热议问题