将文件存储在数据库中而不是文件系统中?
一般来说,与文件系统相比,将文件存储在数据库(特别是 mssql)中对性能的影响有多大?除了应用程序可移植性之外,我想不出其他原因,我希望将我的文件作为 varbinaries 存储在 SQL Server 中.
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.
推荐答案
看看这个答案:
在数据库中存储图像 - 是还是不是?
从本质上讲,空间和性能的影响可能非常大,具体取决于用户数量.此外,请记住,Web 服务器很便宜,您可以轻松添加更多服务器以平衡负载,而数据库通常是 Web 架构中最昂贵且最难扩展的部分.
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.
有一些相反的例子(例如 Microsoft Sharepoint),但通常情况下,将文件存储在数据库中并不是一个好主意.
There are some opposite examples (e.g., Microsoft Sharepoint), but usually, storing files in the database is not a good idea.
除非您可能编写桌面应用程序和/或大致知道您将拥有多少用户,但在诸如公共网站之类的随机和意外情况下,您可能会为在数据库中存储文件付出高昂的代价.
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.
相关文章