max_rows主要对myisam生效,avg_row_length对blob,text字段起作用,以优化存储空间。
max_rows 是配合myisam_data_pointer_size使用的。
官方文档:
To change the default size limit for MyISAM tables, set the myisam_data_pointer_size, which sets the number of bytes
used for internal row pointers. The value is used to set the pointer size for new tables if you do not specify the MAX_ROWS op-
tion. The value of myisam_data_pointer_size can be from 2 to 7. A value of 4 permits tables up to 4GB; a value of 6
permits tables up to 256TB
如果你把max_rows 设为5, 但 myisam_data_pointer_size范围是 2~7, 2个字节就足够了( 2^16=64k), 所以其实就是让myisam是用2个字节的指针,并不是说最多5行。 如果你把max_rows 设为 100k,此时 100K>64K, 就要用3个字节表示,所以myisam_data_pointer_size会设为3, 此时最多存放 2^24行。
mysql> create table t1 (a int) max_rows=2 engine=myisam;
Query OK, 0 rows affected (0.05 sec)
mysql> inser