将文件大小存储在数据库中 [英] Storing File Sizes in a Database

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

问题描述

我目前正在研究涉及存储多个研究及其内容细节的系统(研究通常可以包含1

I am currently working on a system that involves storing multiple studies and details of their contents (A study can typically contain 1 < X < ~2000 images). My colleagues and I were discussing what might be the best method of storing files sizes (specifically the image sizes) in a database would be.

文件大小通常为< 1kB到> 20MB。

The file sizes typically range from < 1kB to > 20MB.

我们正在争取将图像大小存储为:

We are currently debating between storing the images sizes as:

# of kilobytes (as an integer value) 
# of bytes (as a large integer value)
# of megabytes (possibly as a decimal value)
Other Options...

我没有很好地保存文件大小,想知道最有效/实现这个的实用方法?

I haven't worked with storing file sizes much and was wondering what might be the most efficient / practical method of accomplishing this?

推荐答案

没有正确的答案。我喜欢马特的答案是为了精确的原因。我喜欢安倍的答案是为了节省空间...(是的,桌子上的空间比文件系统更有影响力)

There is no right answer. I like Matt's answer for reasons of precision. I like Abe's answer for reasons of space saving... (Yes, space in a table is much more 'impactful' than on the Filesystem)

真正的答案是,你为什么存储价值?这是用于存储数据的用户发票的机制吗?那么你必须依靠合同。这是为了测量驱动器上的空间吗?如果是这样,文件真的占用一些数量的块,而不是一些字节数。如果最小块大小是2KB,那么你应该说每个文件都是2kb的增量...如果你存储那个值,或者那个值2kb是由你决定的。

The real answer is, for what purpose are you storing the value? Is this for a mechanism to invoice the user storing the data? Then you'd have to rely on the contract. Is this to measure space on a drive... if so, files REALLY take up some number of 'blocks' and NOT some number of bytes. If the minimum block size is 2KB then you should say that EVERY file is increments of 2kb... If you store that value or that value times 2kb is up to you.

也许您正在存储该值,因为检索算法具有2个优化路径,一个用于较大的文件,一个用于较小的文件,该进程想知道大小,无需询问文件系统。 (在这种情况下,这可能只是一个is_greater_than_x_kb标志栏。)

Maybe you're storing the value because the retrieval algorithm has 2 optimization paths, one for larger files and one for smaller and that process would like to know the size WITHOUT interrogating the file-system. (in this case maybe just an "is_greater_than_x_kb" flag column is all you need.)

没有人可以告诉你你的要求是什么。现有答案给你的唯一一个是一个意见,而不是一个正确的答案。

No one here can tell you what your requirement is. The only thing the existing answers give you is an opinion, not a right answer.

这篇关于将文件大小存储在数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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