MYSQL TINYBLOB和LONGBLOB [英] MYSQL TINYBLOB vs LONGBLOB

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

问题描述

这是我上一个问题的后续: Blob和存储要求

This is a follow up for my previous question: Blob and Storage Requirement

我使用 SHOW TABLE STATUS 做了一些测试,发现使用的总磁盘空间实际上只取决于上传到数据库的实际文件的大小而不是列的类型(例如TINYBLOB或LONGBLOG)。

I did some testing using SHOW TABLE STATUS, and found out that the total disk space used actually only depends on the size of actual files uploaded to the database and not on the type (e.g. TINYBLOB or LONGBLOG) of the column.

因此,如果不是这样,那么当我们选择一个BLOB类型?

So, if that's not the case then what difference does make when we choose one over the other of the BLOB types?

推荐答案

每个大小的blob字段保留额外的字节来保存大小信息。 longblob使用4 + n字节的存储,其中n是您存储的blob的实际大小。

Each size of blob field reserves extra bytes to hold size information. A longblob uses 4+n bytes of storage, where n is the actual size of the blob you're storing. If you're only ever storing (say) 10 bytes of blob data, you'd be using up 14 bytes of space.

相比之下,tinyblob使用1+字节的数据, n字节,因此您的10个字节将占用11个字节的空间,节省3个字节。

By comparison, a tinyblob uses 1+n bytes, so your 10 bytes would occupy 11 bytes of space, a 3 byte savings.

3个字节在处理几个记录时不多, DB记录计数增长,每保存一个字节是一件好事。

3 bytes isn't much when dealing with only a few records, but as DB record counts grow, every byte saved is a good thing.

这篇关于MYSQL TINYBLOB和LONGBLOB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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