mysql max和avg_【讨论】max_rows和avg_row_length没效了?

max_rows选项主要影响MyISAM表,它与myisam_data_pointer_size配合使用,决定内部行指针的大小。myisam_data_pointer_size的设置影响表的最大容量。当max_rows超出由myisam_data_pointer_size指定的字节数所能表示的行数时,将导致错误。在示例中,当max_rows设为2时,实际允许的最大行数为65535,超过此限制会提示'The table is full'错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值