How to compute the disk space usage of a row in a mysql innodb table -
i have application inserts many rows in specific innodb table , don't know how compute disk space needed in future.
so given mysql innodb table structure, how can compute disk space cost of row?
- tinyint consumes 1 byte, int: 4 bytes, bigint: 8 bytes, text/blob/varchar/varbinary: 2+ average number of bytes, datetime , timestamp: 5 bytes, char takes full length, etc.
- add up, based on columns in table.
- multiple 3 (for overhead, indexes, btree structure, wasted space, etc, etc). give crude estimate of disk space innodb row.
caveats:
- the result high or low, simple first guess.
- a table take minimum of 16kb.
- an excessive number of secondary indexes lead more space consumed.
- lots of texts/blobs can lead off-record storage exceed forumla.
- at point during growth of table, allocation unit switches 16kb 8mb, thereby leading disturbing jumps in size.
- row_format makes difference. (but compressed unlikely shrink table more 2x.)
- look ways shrink uuids, ip addresses, etc, save space.
- don't use utf8 ascii-only char() strings (country_code, hex, etc).
Comments
Post a Comment