所以我用的是一个在数据库中大量存储图像的应用程序。你对此有什么看法?我更倾向于将位置存储在文件系统中,而不是直接存储在DB中。
你认为优点和缺点是什么?
所以我用的是一个在数据库中大量存储图像的应用程序。你对此有什么看法?我更倾向于将位置存储在文件系统中,而不是直接存储在DB中。
你认为优点和缺点是什么?
当前回答
将图像存储在文件系统中的另一个好处是,您不需要做任何特殊的事情来让客户端缓存它们……
...当然,除非图像不能通过文档根访问(例如身份验证障碍),在这种情况下,你需要检查你的代码正在发送的缓存控制头。
其他回答
你的网络服务器(我假设你正在使用)是用来处理图像的,而数据库不是。因此,我会大力投反对票。
在数据库中只存储路径(可能还有文件信息)。
如果您使用Teradata,那么Teradata Developer Exchange有一篇关于加载和检索lobs和blobs的详细文章。
http://developer.teradata.com/applications/articles/large-objects-part-1-loading
当然是文件系统。然后你可以使用所有的操作系统功能来处理这些图像-备份,web服务器,甚至只是使用imagemic之类的工具进行批量修改。如果您将它们存储在DB中,那么您需要编写自己的代码来解决这些问题。
我更喜欢将图像路径存储在DB中,并将图像存储在文件系统中(在服务器之间使用rsync以保持所有内容的合理最新)。
然而,我所做的一些内容管理系统的工作需要在CMS中使用图像,原因有几个——可见性控制(因此资产被保留到新闻稿发布之前)、版本控制、重新格式化(一些CMS将动态调整缩略图的大小)以及将图像链接到所见即所得页面的易用性。
因此,我的经验法则是始终将应用程序的内容保存在文件系统中,除非它是CMS驱动的。
我负责一些管理许多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