所以我用的是一个在数据库中大量存储图像的应用程序。你对此有什么看法?我更倾向于将位置存储在文件系统中,而不是直接存储在DB中。

你认为优点和缺点是什么?


当前回答

在数据库中存储图像仍然意味着图像数据最终位于文件系统中的某个位置,但被遮蔽,因此您不能直接访问它。

+压力:

数据库的完整性 它易于管理,因为您不必担心在添加或删除映像时保持文件系统同步

-维斯:

性能损失——数据库查找通常比文件系统查找慢 您不能直接编辑图像(裁剪,调整大小)

这两种方法都是常见的和实践的。看看优点和缺点。无论哪种方式,你都必须考虑如何克服缺点。在数据库中存储通常意味着调整数据库参数并实现某种缓存。使用文件系统要求您找到某种保持文件系统+数据库同步的方法。

其他回答

我负责一些管理许多TB图像的应用程序。我们发现在数据库中存储文件路径是最好的。

这里有几个问题:

database storage is usually more expensive than file system storage you can super-accelerate file system access with standard off the shelf products for example, many web servers use the operating system's sendfile() system call to asynchronously send a file directly from the file system to the network interface. Images stored in a database don't benefit from this optimization. things like web servers, etc, need no special coding or processing to access images in the file system databases win out where transactional integrity between the image and metadata are important. it is more complex to manage integrity between db metadata and file system data it is difficult (within the context of a web application) to guarantee data has been flushed to disk on the filesystem

我将采用文件系统方法。正如其他一些人所指出的,大多数web服务器被构建为从文件路径发送图像。如果您不需要从数据库中写入或输出BLOB字段,那么您将获得更高的性能。当内容不变或希望限制数据库负载时,将图像存储在文件系统中可以更容易地设置静态页面。

我是一个企业文档管理系统的首席开发人员,一些客户在这个系统中存储了数百gb的文档。在不久的将来会达到tb级。我们使用文件系统方法是出于本页提到的许多原因,另外还有一个原因:存档。

我们的许多客户必须遵守行业特定的存档规则,例如存储到光盘或非专有格式的存储。此外,您还可以灵活地向NAS设备添加更多磁盘。如果你把文件存储在你的数据库中,即使使用SQL Server 2008的文件流数据类型,你的存档选项也会变得非常狭窄。

通过网络将二进制数据从数据库中取出会导致巨大的延迟问题,并且伸缩性不好。

将路径存储在数据库中,让你的web服务器承担负载——这就是它的设计目的!

你的网络服务器(我假设你正在使用)是用来处理图像的,而数据库不是。因此,我会大力投反对票。

在数据库中只存储路径(可能还有文件信息)。