Possible Duplicate:
Storing Images in DB - Yea or Nay?

Which approach is much better? What exactly are the pros and cons?

Benefits of storing images in database, for me, are:

  • database integrity (it's simpler to help keep all database records valid with foreign secrets rather than keep close track of filesystem making needed changes there throughout each alternation in database)
  • less work and simpler maintenance (you only have to take proper care of one host to data storage - database)

Disadvantage would imho be:

  • greater strain on database server

Would you accept the points above?

Presently things i do is I store small images for example avatars and pictures within the database as BLOBs and that i store large images for example full-sized photos or wallpapers within the filesystem. Do you consider this is an excellent approach? If so, can there be some miracle number (quality) that decides whether it's still beneficial to keep a picture within the database or otherwise? Otherwise, must i store all images just in one location (database or filesystem)?

I have had major perf problems trying to keep images within the database. The database size will get a great deal bigger and queries on tables with BLOB's be a lot reduced. Additionally, it adds additional complexity your code as make use of non standard data use of retrieve your images and also have to configure for lazy loading. Additionally, it considerably increases backup and replication occasions.

Storing in files is a lot simpler to deal with, it is simple to backup and rsync only those that have transformed.

Essentially I never make an effort to blob anything apart from metadata right into a database.

IMHO binary data doesn't have place to stay in a database. (obviously there might be exception for this rule)