Db vs Filesystem for Binary contnet


I'm debating between storing binary content (i.e. images) in the db (mysql) or the filesystem. I like the idea of the database because everything is in one place, but I've heard using the filesystem has better performance. Is storing binary content in the database a performance hit vs. the file system, or is it just an old wives tale? If I'm going to be writing queries against a table's non-binary fields will I face performance hits because binary columns appear in the table?

Anyone have any thoughts?

Thanks in advance. Scott.

Re: [Rails] Db vs Filesystem for Binary contnet I hate managing backups of databases with lots of binary content. Resurrecting a damaged one is next to impossible. OTOH, everything really is in one place, which makes insert and delete more atomic. From a performance perspective, it will depend on how hard you expect your database to be hit. If the database is local, you shouldn’t suffer much performance. If the database is remote, the round-trip cost adds up in a hurry. If performance is your concern, measure a sample under your projected load on hardware similar to what you plan to deploy to.


Besides the weak "keeping everything in one place" argument, I can't think of any pros of storing binary files in the db.

Well, an extension of that argument is that if your images are to be dynamically resized on a regular basis or anything like that (so image requests will have to be dynamic whether on the db or not), it makes it so much easier to program. But I still think having images on the file system is well worth the extra time and effort in almost any circumstance.

This is one of those subjects that comes up every 2-4 weeks.