存储文件的最佳方法 [英] Best way to store files

查看:60
本文介绍了存储文件的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在服务器上存储上传文件的标准方法是什么?是数据库中的binary还是硬盘上的路径存储在数据库中?

What is the standard way to store uploaded files on server? In database as binary or on hard disk with path stored in database?

推荐答案

Microsoft对此主题进行了研究:

Microsoft did a research in this topic: https://www.microsoft.com/en-us/research/publication/to-blob-or-not-to-blob-large-object-storage-in-a-database-or-a-filesystem/

存储非常小的文件将使您在数据库中获得最佳性能.存储较大的文件可为您的硬盘提供最佳性能.我为我工作的公司进行了研究.当文件大小为512 kB或更大时,文件系统性能将比数据库更好.此后,数据库的性能将迅速下降.

Storing very small files will get you the best performance in the database. Storing larger files give you the best performance on your hard drive. I researched this for a company where I work for. The file system performance will be better than the database when the file size is 512 kB or larger. The performance of the database will drop rapidly after this point.

将文件存储在数据库中将为您提供可以使所有内容保持同步的优势.您可以配置为在删除文件记录时将删除文件BLOB.但是,存储大文件会给您带来非常糟糕的性能,并且创建备份可能会花费很长时间.

Storing files in the database will give you the advantage that you can keep everything in sync. You can configure that a file BLOB will be removed when the file record is removed. However, storing large files will give you very bad performance and creating backups could take very long.

这篇关于存储文件的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆