<p>Generally, how bad of a performance hit is storing a file in a database (specifically mssql) as opposed to the file system?  I can't come up with a reason outside of application portability that I would want to store my files as varbinaries in SQL Server.</p>

[{'answer_id': 8955, 'author': 'ZombieSheep', 'author_id': 377, 'author_profile': 'https://Stackoverflow.com/users/377', 'pm_score': 3, 'selected': False, 'text': "<p>In my own experience, it is always better to store files as files.  The reason is that the filesystem is optimised for file storeage, whereas a database is not.  Of course, there are some exceptions (e.g. the much heralded next-gen MS filesystem is supposed to be built on top of SQL server), but in general that's my rule.  </p>\n"}, {'answer_id': 8960, 'author': 'Michael Stum', 'author_id': 91, 'author_profile': 'https://Stackoverflow.com/users/91', 'pm_score': 7, 'selected': True, 'text': '<p>Have a look at this answer:</p>\n\n<p><a href="https://stackoverflow.com/questions/3748/storing-images-in-db-yea-or-nay#3756">Storing Images in DB - Yea or Nay?</a></p>\n\n<p>Essentially, the space and performance hit can be quite big, depending on the number of users. Also, keep in mind that Web servers are cheap and you can easily add more to balance the load, whereas the database is the most expensive and hardest to scale part of a web architecture usually.</p>\n\n<p>There are some opposite examples (e.g., Microsoft Sharepoint), but usually, storing files in the database is not a good idea.</p>\n\n<p>Unless possibly you write desktop apps and/or know roughly how many users you will ever have, but on something as random and unexpectable like a public web site,  you may pay a high price for storing files in the database.</p>\n'}, {'answer_id': 8961, 'author': 'Will Dean', 'author_id': 987, 'author_profile': 'https://Stackoverflow.com/users/987', 'pm_score': 3, 'selected': False, 'text': '<p>What\'s the question here?</p>\n\n<p>Modern DBMS SQL2008 have a variety of ways of dealing with BLOBs which aren\'t just sticking in them in a table.  There are pros and cons, of course, and you might need to think about it a little deeper.</p>\n\n<p>This is an interesting paper, by the late (?) Jim Gray</p>\n\n<p><a href="https://www.microsoft.com/en-us/research/publication/to-blob-or-not-to-blob-large-object-storage-in-a-database-or-a-filesystem/" rel="nofollow noreferrer">To BLOB or Not To BLOB: Large Object Storage in a Database or a Filesystem</a></p>\n'}, {'answer_id': 8963, 'author': 'martinsb', 'author_id': 837, 'author_profile': 'https://Stackoverflow.com/users/837', 'pm_score': 1, 'selected': False, 'text': "<p>I agree with @ZombieSheep.\nJust one more thing - I generally don't think that databases actually need be portable because you miss all the features your DBMS vendor provides. I think that migrating to another database would be the last thing one would consider. Just my $.02</p>\n"}, {'answer_id': 8969, 'author': 'Jon Limjap', 'author_id': 372, 'author_profile': 'https://Stackoverflow.com/users/372', 'pm_score': 1, 'selected': False, 'text': '<p>The overhead of having to parse a blob (image) into a byte array and then write it to disk in the proper file name and then reading it is enough of an overhead hit to discourage you from doing this too often, especially if the files are rather large.</p>\n'}, {'answer_id': 8981, 'author': 'Jon Galloway', 'author_id': 5, 'author_profile': 'https://Stackoverflow.com/users/5', 'pm_score': 5, 'selected': False, 'text': '<p>If you can move to SQL Server 2008, you can take advantage of the FILESTREAM support which gives you the best of both - the files are stored in the filesystem, but the database integration is much better than just storing a filepath in a varchar field. Your query can return a standard .NET file stream, which makes the integration a lot simpler.</p>\n\n<p><a href="http://msdn.microsoft.com/en-us/library/bb933995.aspx" rel="noreferrer">Getting Started with FILESTREAM Storage</a></p>\n'}, {'answer_id': 8992, 'author': 'Shawn Miller', 'author_id': 247, 'author_profile': 'https://Stackoverflow.com/users/247', 'pm_score': 2, 'selected': False, 'text': '<p>We made the decision to store as varbinary for <a href="http://www.freshlogicstudios.com/Products/Folders/" rel="nofollow noreferrer">http://www.freshlogicstudios.com/Products/Folders/</a> halfway expecting performance issues.  I can say that we\'ve been pleasantly surprised at how well it\'s worked out.</p>\n'}, {'answer_id': 9087, 'author': 'Lance Fisher', 'author_id': 571, 'author_profile': 'https://Stackoverflow.com/users/571', 'pm_score': 5, 'selected': False, 'text': "<p>I'd say, it depends on your situation.  For example, I work in local government, and we have lots of images like mugshots, etc.  We don't have a high number of users, but we need to have good security and auditing around the data.  The database is a better solution for us since it makes this easier and we aren't going to run into scaling problems.</p>\n"}, {'answer_id': 9094, 'author': 'N8g', 'author_id': 1104, 'author_profile': 'https://Stackoverflow.com/users/1104', 'pm_score': 0, 'selected': False, 'text': "<p>Not to be vague or anything but I think the type of 'file' you will be storing is one of the biggest determining factors. If you essentially talking about a large text field which could be stored as file my preference would be for db storage. </p>\n"}, {'answer_id': 31436, 'author': 'Marcus Downing', 'author_id': 1000, 'author_profile': 'https://Stackoverflow.com/users/1000', 'pm_score': 2, 'selected': False, 'text': "<p>While performance is an issue, I think modern database designs have made it much less of an issue for small files.</p>\n\n<p>Performance aside, it also depends on just how tightly-coupled the data is. If the file contains data that is closely related to the fields of the database, then it conceptually belongs close to it and may be stored in a blob. If it contains information which could potentially relate to multiple records or may have some use outside of the context of the database, then it belongs outside. For example, an image on a web page is fetched on a separate request from the page that links to it, so it may belong outside (depending on the specific design and security considerations).</p>\n\n<p>Our compromise, and I don't promise it's the best, has been to store smallish XML files in the database but images and other files outside it.</p>\n"}]
['https://Stackoverflow.com/questions/8952', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/565/']