MySQL + MyISAM table size question
- by alessandro ferrucci
Hello,
I have a test table. The test table is as follows:
CREATE TABLE mytest (
num1 int(10) unsigned NOT NULL,
KEY key1 (num1)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
I inserted 50 million rows in this table.
When I do show table status the avg_row_length is 7. I was expecting to see 4 since mySQL uses 4 bytes for integers. Does the key have an effect on the avg_row_length? When I look at my .MYD file the size is 334 MB which is exactly what it should be given that the avg_row_length is 7, however I was really expecting to see 190 MB given that I only have an int.
+----------------+--------+---------+------------+----------+----------------+-------------+------------------+--------------+-----------+----------------+---------------------+---------------------+------------+-------------------+----------+----------------+---------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |
+----------------+--------+---------+------------+----------+----------------+-------------+------------------+--------------+-----------+----------------+---------------------+---------------------+------------+-------------------+----------+----------------+---------+
| mytest | MyISAM | 10 | Fixed | 50000000 | 7 | 350000000 | 1970324836974591 | 600518656 | 0 | NULL | 2010-05-22 09:15:06 | 2010-05-22 19:32:53 | NULL | latin1_swedish_ci | NULL | | |
I have included the output of show table status for mytest table. Sorry about the formatting :D
Thanks in advance!
Alessandro Ferrucci