Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

marked as duplicate by gnat, GlenH7, MichaelT, Kilian Foth, DougM Jan 29 '14 at 13:30

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

see this question:… – Kirk Broadhurst Nov 23 '11 at 6:02

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.

share|improve this answer

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. 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

share|improve this answer
Marking your answer "community wiki" will prevent rep change due to upvotes. – kevin cline Nov 23 '11 at 14:33
I don't know how to do that :-( – Pankaj Upadhyay Nov 23 '11 at 14:43
there is a checkbox at the lower right of the answer text box. – kevin cline Nov 23 '11 at 15:08

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