mysql 确定字段的存储大小
我想知道是否有mysql命令来确定mysql字段当前使用的实际存储大小。
也许类似“showused_storage myfield FROM ... WHERE ...”之类的东西,
奇怪的是我能找到这样的东西。
(同样对于 postgresql 也很有趣)
非常感谢!
i would like to know if there is a mysql command to determine the currently used actual storage size of a mysql field.
Maybe something like "show used_storage myfield FROM ... WHERE ..."
Oddly I couln'd find anything like this.
(The same for postgresql would be interessting too)
Thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于 PostgreSQL,您可以使用
此类函数的完整列表在手册中
http://www.postgresql.org/docs/current/static/functions -admin.html
For PostgreSQL you can use
A complete list of this kind of functions is in the manual
http://www.postgresql.org/docs/current/static/functions-admin.html
如果您使用的是字符数据字段,最简单的方法是
如果您使用的是某种数字数据类型,您只需获取行数,然后将其乘以大小,例如 4 表示 INTEGER,或 8 表示 DOUBLE。
但它不会反映磁盘上实际占用的大小。这可能更难找到。即使它是准确的,由于碎片和其他因素,表的实际大小也可能远远大于所有列的总大小。
您可以通过以下方式获取整个表的大小(和索引大小):
如果您仅将所需的列复制到新的临时表中,您可能能够更真实地了解您的字段实际占用了多少空间到磁盘上。
If you are using a character data field, the simplest would be
If you are using some numerical data type, you could just get a count on the rows, and multiply it by the size, for instance 4 for INTEGER, or 8 for DOUBLE.
It won't reflect the actual size taken up on disk however. This is probably a lot more difficult to find out. And even if it was accurate, the actual size of the table could be much more than the total size of all the columns due to fragmentation and other factors.
You can get the size (and index size) of an entire table with:
If you copy out just the column you want to a new temporary table, you may be able to get a more realistic view of how much space your field is actually taking up on disk.
MySQL 记录空间利用率:
http://dev.mysql.com/ doc/refman/5.0/en/storage-requirements.html
MySQL documents space utilization:
http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html