存储性能
我想让用户能够上传图像和视频到网站。 现在的问题是,我应该将所有文件放在一个文件夹中还是为每个用户创建一个文件夹? (当然会更容易找到)
它对性能有影响吗? 访问速度有什么区别吗?
谢谢
I want to enable users to upload images & videos to a website.
Question is now, shall I just drop all the files in one folder or make a folder e.g. for each user?
(Of course it would be easier to find)
Does it make a difference in the performance?
Is it any difference in the access rate?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您正在处理许多文件,则将文件分布在多个(子)目录中是一个常见原则。这是因为如果一个目录包含太多目录和文件,文件系统需要做更多的工作。分发文件会有所帮助。
但这始终取决于您用作数据库的底层文件系统。您需要查看您使用的是哪一个,然后检查它支持的功能以及给出的限制。
在应用程序层上,您应该对文件访问和处理进行建模,以便稍后可以更改应用程序存储文件的方式,而无需重写整个应用程序。
If you're dealing with many files, it's a common principle to distribute the files across multiple (sub-) directories. This is because if a directory contains too many directories and files, the file-system needs to do more work. Distributing the files helps then.
But this always depends on the underlying-file-system you use as a database. You need to look which one you use and then check the features it supports and which limits are given.
On the application layer, you should model file-access and handling so you can change how your application stores the files later on w/o rewriting your whole application.