当每个条目都适合中等文本大小的字段时,使用 MySQL 长文本大小的字段有什么缺点?
当每个条目都适合中等文本大小的字段时,使用 MySQL 长文本大小的字段有什么缺点?
我问的原因是因为我有一些长文本大小的字段,最近意识到它们太大了,但后来努力激励自己做出微小的改变,因为“有什么害处?”因此这个问题。
What is the disadvantage to using a MySQL longtext sized field when every entry will fit within a mediumtext sized field?
The reason I am asking is because I have some longtext sized fields and recently realized they are much too large, but then struggled with motivating myself to make the minute change because "what's the harm?" hence the question.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
唯一的存储大小差异是为“该字段有多少字节”数字分配的字节数。来自精细手册:
所以一个
长文本
将比mediumtext
多使用一个字节来存储相同的文本。 数据类型存储要求 手册部分以及BLOB 和 TEXT 类型 部分。四种 TEXT 类型之间没有实际区别。
The only storage size difference is the number of bytes allocated for the "how many bytes is this field" number. From the fine manual:
So a
longtext
will use one more byte thanmediumtext
to store the same text. There is a bit more information in the Data Type Storage Requirements section of the manual and some more in the The BLOB and TEXT Types section.There's no practical difference between the four TEXT types.
MySQL 多次使用临时表来执行查询。
因此,拥有大尺寸字段的缺点是 MySQL 将为列保留那么多空间。
如果将该列标记为长文本(与中文本相比),则相同数据的执行速度会很慢。
MySQL uses temporary tables a lot of times to execute queries.
So the disadvantage of having large sized field is that MySQL will reserve that much space for the column.
You will have slow execution with same data if you have that column marked as longtext compared to mediumtext.