InnoDB 行大小比 MyIsam 大
我有一个表,其中包含列、一个smallint、一个整数和两个浮点数。每行的预期内存为 14 字节 (2+4+2*4)。 我的表中有大约 700,000 行。我没有设置主键和索引。 MyIsam 类型大约需要 10MB(平均每行 15b),而 InnoDB 类型则需要超过 30Mb(平均每行 44b)。 我在这里缺少什么? InnoDB 是否会对每一行产生如此大的开销,或者表状态数字不可信。 我需要存储的数据将达到 GB,因此需要通过权衡不同的参数来决定存储类型。
I have a table with for columns, a smallint, an integer and two floats. Expected memory for each row is 14bytes (2+4+2*4).
I have around 700,000 rows in my table. I've set no primary keys and indices.
While the MyIsam type takes around 10MB (average of 15b for each row), the InnoDB type takes more than 30Mb (average of 44b).
What am I missing here? Would InnoDB have so much of overhead for each row, or are the table status number not to be trusted.
I need to store data which will run into GBs, so need to decide on the storage type by weighing different parameters.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
与 MyISAM 相比,InnoDB 表确实占用更多空间。您必须决定存储使用和 InnoDB 提供的功能(崩溃安全、事务和外键)之间的权衡是否有利于 InnoDB。当我从 MyISAM 切换到 InnoDB 后,我就不会再回去了。
值得注意的是,如果您打算继续使用 InnoDB,您肯定会想要定义一个主键(最好是一个短的主键)。这是由于 InnoDB 对于存储和其他索引的行为方式造成的。请参阅此页面。
InnoDB tables do take up more space when compared to MyISAM. Whether the trade-off between storage use and the features offered by InnoDB (crash-safety, transactions, and foreign keys) favours InnoDB is something you will have to decide on. Having myself switched from MyISAM to InnoDB, I wouldn't go back.
It's worth noting that if you are going to go ahead and use InnoDB, you will definitely want to define a primary key (and ideally a short one). This is due to the way InnoDB behaves wrt storage and other indices. See this page.