【bug】 1118 Row size too large

2023-05-18,,

1118 Row size too large

Every table (regardless of storage engine) has a maximum row size of 65,535 bytes.
Storage engines may place additional constraints on this limit, reducing the effective maximum row size.

innodb_version : 5.5.56

Like other InnoDB tables it has all the InnoDB limitations, i.e.,
InnoDB row or column limits. If it exceeds these, it will return “Row size too large” or “Too many columns” errors.
The workaround is to set internal_tmp_disk_storage_engine to MYISAM.

提供3种解决途径 (根据需要选其一即可),我采用的是第3种方法

1.innodb_log_file_size innodb_log_file_size = 500M innodb_strict_mode = 0
2.storage_engine = MyISAM
3.innodb_file_per_table=ON innodb_file_format = Barracuda internal_tmp_disk_storage_engine=MyISAM

按照第3种方法修改配置文件
修改全局变量 set global innodb_file_format  = 'Barracuda'
修改表文件存储方式  alter table table_name ENgine = 'innodb' ROW_FORMAT = COMPRESSED KEY_BLOCK_SIZE=8 ;
完成

下面是一些调试语句,可以选择性使用
innodb_log_file_size = 5120M (5242880)
innodb_strict_mode = off
innodb_file_per_table = ON

show variables like "%format%";

innodb_file_format Barracuda
innodb_file_format_max Barracuda

show table status like '%table_name%';
row_format compact

alter table table_name ENgine = 'innodb' ROW_FORMAT = COMPRESSED KEY_BLOCK_SIZE=8 ;

show table status like '%table_name%';
row_format compressed

fixed-length dynamic-length compress

InnoDB Plugin引入了新的文件格式(file format,可以理解为新的页格式),
对于以前支持的Compact和Redundant格式将其称为Antelope文件格式,
新的文件格式称为Barracuda。Barracuda文件格式下拥有两种新的行记录格式Compressed和Dynamic两种。
新的两种格式对于存放BLOB的数据采用了完全的行溢出的方式,在数据页中只存放20个字节的指针,实际的数据都存放在BLOB Page中,
而之前的Compact和Redundant两种格式会存放768个前缀字节。

Compressed行记录格式的另一个功能就是,存储在其中的行数据会以zlib的算法进行压缩,
因此对于BLOB、TEXT、VARCHAR这类大长度类型的数据能进行非常有效的存储。

提供另外2中思路

分表,把复杂的字段提取出来单独存放
能否从代码层面规避这种问题,通过代码优化实现

【bug】 1118 Row size too large的相关教程结束。

《【bug】 1118 Row size too large.doc》

下载本文的Word格式文档,以方便收藏与打印。