Possible Duplicate:
Storing Images in DB - Yea or Nay?
Which approach is better? What are the advantages and disadvantages?
Advantages of storing images in database, in my opinion, are:
Disadvantage would imho be:
Do you agree with the points above?
Currently what I do is I store small images such as avatars and thumbnails in the database as BLOBs and I store large images such as full size photos or wallpapers in the filesystem. Do you think this is a good approach? If yes, is there some magic number (file size) that decides if it's still advantageous to store an image in the database or not? If not, should I store all images just in one place (database or filesystem)?
I've had major perf problems attempting to store images in the database. The database size gets a lot larger and queries on tables with BLOB's become a lot slower. It also adds additional complexity your code as you have to use non standard data access to retrieve your images and have to configure for lazy loading. It also significantly increases backup and replication times.
Storing in files is much easier to handle, you can easily backup and rsync only the ones that have changed.
Basically I never attempt to blob anything other than metadata into a database.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With