SQL 将图像存储在数据库中还是系统文件中?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/766048/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 01:45:21  来源:igfitidea点击:

store image in database or in a system file?

.netsqldatabase

提问by Hannoun Yassir

Exact Duplicate:User Images: Database or filesystem storage?
Exact Duplicate:Storing images in database: Yea or nay?
Exact Duplicate:Should I store my images in the database or folders?
Exact Duplicate:Would you store binary data in database or folders?
Exact Duplicate:Store pictures as files or or the database for a web app?
Exact Duplicate:Storing a small number of images: blob or fs?

完全重复:用户图像:数据库还是文件系统存储?
完全重复:在数据库中存储图像:是还是不是?
完全重复:我应该将图像存储在数据库还是文件夹中?
完全重复:您会将二进制数据存储在数据库或文件夹中吗?
完全重复:将图片存储为文件或网络应用程序的数据库?
完全重复:存储少量图像:blob 还是 fs?

I have to store user's profile image (100px * 100px) what is the best way to store it ? database or system file ? which one is better , faster ,safer ... ?

我必须存储用户的个人资料图片 (100px * 100px) 什么是最好的存储方式?数据库或系统文件?哪个更好、更快、更安全……?

回答by Anton Gogolev

SQL Server 2008 offers the best of both worlds.

SQL Server 2008 提供了两全其美的优势

回答by Tomas Aschan

Alwaysstore images, music files etc in system files on disk, and then store the url:s to them in the database. That will make it

始终将图像、音乐文件等存储在磁盘上的系统文件中,然后将它们的 url:s 存储在数据库中。这将使它

1) faster

1)更快

2) easier to configure security settings

2)更容易配置安全设置

3) better in any ways I can imagine

3)在我能想象的任何方面都更好

回答by James Avery

I am going to propose a third option, a third-party party place like Amazon S3 or Mosso Cloud Files. Both provide APIs that you can use to upload the file and both provide CDN capabilities so the files will load quicker then they would off your servers or pulling from your database.

我将提出第三种选择,第三方场所,如 Amazon S3 或 Mosso Cloud Files。两者都提供可用于上传文件的 API,并且都提供 CDN 功能,因此文件加载速度比从服务器或从数据库中提取的速度更快。

This is a nice option because it is the best of both worlds. The downside of storing images in the database is that it is additional stress on your application and database servers (locating the file and pulling it) and it also causes your database to grow in size which can mean you will need more hardware earlier.

这是一个不错的选择,因为它是两全其美的。将图像存储在数据库中的缺点是它会给您的应用程序和数据库服务器(定位文件并拉取文件)带来额外的压力,并且还会导致您的数据库变大,这意味着您将需要更多的硬件。

The downside of storing them in the file system is that you now have an issue with scaling as if you want to add additional web servers they would each need a copy of the image or you would need create a dedicated server for these images. Also, file system access could be a future bottleneck to worry about.

将它们存储在文件系统中的缺点是您现在遇到了扩展问题,就像您想添加额外的 Web 服务器一样,它们每个都需要图像的副本,或者您需要为这些图像创建一个专用服务器。此外,文件系统访问可能是未来需要担心的瓶颈。

回答by oscarkuo

database makes it easier to backup and restore and it works better than file system storage for small images. Microsoft had published a research paper on this topic: To BLOB or Not To BLOB.

数据库使备份和恢复更容易,对于小图像,它比文件系统存储更有效。微软已经发表了一篇关于这个主题的研究论文:To BLOB or Not To BLOB