所以我用的是一个在数据库中大量存储图像的应用程序。你对此有什么看法?我更倾向于将位置存储在文件系统中,而不是直接存储在DB中。
你认为优点和缺点是什么?
所以我用的是一个在数据库中大量存储图像的应用程序。你对此有什么看法?我更倾向于将位置存储在文件系统中,而不是直接存储在DB中。
你认为优点和缺点是什么?
当前回答
尝试使用SQL模拟文件系统通常是一个糟糕的计划。如果您坚持使用文件系统作为外部存储,那么最终编写的代码会更少,结果也会更好。
其他回答
通常,我强烈反对采用基础设施中最昂贵和最难扩展的部分(数据库),并将所有负载都放在其中。另一方面:它极大地简化了备份策略,特别是当你有多个web服务器,需要以某种方式保持数据同步时。
像大多数其他事情一样,这取决于预期的规模和预算。
The word on the street is that unless you are a database vendor trying to prove that your database can do it (like, let's say Microsoft boasting about Terraserver storing a bajillion images in SQL Server) it's not a very good idea. When the alternative - storing images on file servers and paths in the database is so much easier, why bother? Blob fields are kind of like the off-road capabilities of SUVs - most people don't use them, those who do usually get in trouble, and then there are those who do, but only for the fun of it.
不,因为页面分割。实际上,您定义的行可以是1KB - n MB,因此数据库的页面中会有大量空白,这对性能不利。
我们实现了一个文档成像系统,它将所有图像存储在SQL2005 blob字段中。目前有几百GB,我们看到了出色的响应时间和很少或没有性能下降。此外,fr法规遵从性,我们有一个中间件层,将新发布的文档归档到光学点唱机系统,该系统将它们公开为标准NTFS文件系统。
我们对结果非常满意,特别是在以下方面:
易于复制和备份 能够轻松实现文档版本控制系统
I'm not sure how much of a "real world" example this is, but I currently have an application out there that stores details for a trading card game, including the images for the cards. Granted the record count for the database is only 2851 records to date, but given the fact that certain cards have are released multiple times and have alternate artwork, it was actually more efficient sizewise to scan the "primary square" of the artwork and then dynamically generate the border and miscellaneous effects for the card when requested.
这个图像库的最初创建者创建了一个数据访问类,它根据请求呈现图像,并且对于查看和单独的卡片来说,它的速度非常快。
This also eases deployment/updates when new cards are released, instead of zipping up an entire folder of images and sending those down the pipe and ensuring the proper folder structure is created, I simply update the database and have the user download it again. This currently sizes up to 56MB, which isn't great, but I'm working on an incremental update feature for future releases. In addition, there is a "no images" version of the application that allows those over dial-up to get the application without the download delay.
到目前为止,这个解决方案工作得很好,因为应用程序本身被定位为桌面上的单个实例。有一个网站将所有这些数据存档,以供在线访问,但我绝不会使用相同的解决方案。我同意文件访问更可取,因为它可以更好地适应图像请求的频率和数量。
希望这不是太多的废话,但我看到了这个主题,并想从一个相对成功的中小型应用程序中提供一些我的见解。