I work in a Web Application where users are allowed to upload files. They can retrieve and view those files at a later point in time. A solution that user works with can have multiple attachments but the click to view only one at a time. No version maintenance. Users can delete those files. No soft delete. The files are captured with few more fields on the UI and those fields are stored in DB2 table. Files can be max of 5 MB.

Now, would it be appropriate to store these files in DB2 database as BLOB objects (or) would it be appropriate to store them in a folder? What is the best approach?


2 Answers 2


If you will only have a small number of files (say, under 10,000) and they are fairly small (such as photos), keep them wherever you want - in the db or in the file structure. The difference in performance/efficiency wont be noticable for most applications, so just use whichever you are most comfortable with.

Otherwise, you'll find it easier to manage in the long run if they are stored in the file system. Particularly if these are very important documents - you'll be able to implement much better backup systems, and you wont have to worry about a huge database that will have to span volumes, which may make it difficult to back up.

Keep in mind also, particularly with web applications, the delivery of files stored in the file system does not require using a database connection to transfer the actual file. Whereas if its in a blob, a database connection and its bandwidth are used.


Courtesy Jeff O

Although this has been asked on StackOverflow, I think there is an automatic assumption among programmers on this subject that may not always hold true, so I'm answering it here. There are situations where placing in the database may be better.

https://stackoverflow.com/questions/5613898/what-about-storing-images-in-sql-server There is a link here that shows file size may matter and placing small images in a database may be better for performance. Currently, 250K to 1 M seems to be the grey area. This is specific to SQL Server 2008. I'm guessing more relational databases are going to break their mold a bit and begin to improve their ability to handle large blobs of data.

They may even be better at indexing and searching blob content. Can't wait for the day when I can query all pictures for those Where Photos.File.FaceCount > 1 to get group photos without someone having to manually create the metadata.

NOTE Please don't upvote this answer, this is just for the OP reference. The words are from someone else's mouth so i should not be the one getting the repo's

  • Marking your answer "community wiki" will prevent rep change due to upvotes. Nov 23, 2011 at 14:33
  • I don't know how to do that :-( Nov 23, 2011 at 14:43
  • there is a checkbox at the lower right of the answer text box. Nov 23, 2011 at 15:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.