When is using MySQL BLOB recommended?
Read:
- MySQL Binary Storage using BLOB VS OS File System: large files, large quantities, large problems
- To Do or Not to Do: Store Images in a Database
which concludes
If you on occasion need to retrieve an image and it has to be available on several different web servers. But I think that's pretty much it.
- If it doesn't have to be available on several servers, it's always better to put them in the file system.
- If it has to be available on several servers and there's actually some kind of load in the system, you'll need some kind of distributed storage.
If you are using MyISAM db engine then BLOB fields can be indexed so you can perform quick searches on your files using the database.
Also another advantage of storing files in BLOB fields is that they can be accessed more efficiently than files on the disk (there is no need for directory traversal, open, read, close).
If you are planning to store lots of files in MYSQL, it's usually a good practice to have the files stored in a separate table. This allows you to scan the meta info without stumbling over the blobs. Then, when you actually need to fetch a blob, the JOIN is adequately efficient.