MySQL BLOB vs File for Storing Small PNG Images?

17,660

Solution 1

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!

Solution 2

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.

Share:
17,660
cjroth
Author by

cjroth

See my GitHub an my personal website for info.

Updated on June 18, 2022

Comments

  • cjroth
    cjroth almost 2 years

    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?