起因: 團(tuán)購(gòu)開(kāi)發(fā)報(bào)告說(shuō)更新時(shí)出錯(cuò)。 更新SQL如下: 復(fù)制代碼 代碼如下: UPDATE table_name d SET d.column_name='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' WHERE d.ID=100976; 報(bào)錯(cuò)信息如下: Error Code : 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. You have to change some columns to TEXT or BLOBs 疑惑: 更新字段只涉及 column_name字段,且該字段是TEXT類型。 個(gè)人之前理解是: TEXT的內(nèi)容在 Dynamic的table format下是存在off-page中的,不會(huì)占用row size的計(jì)算。 Barracuda 對(duì)應(yīng)row_format ( dynamic, compress) ,其中dynamic下text的所有內(nèi)容都是off-page存放的 (點(diǎn)擊查看) Antelope 對(duì)應(yīng)row_format (compact, redundant),其中compact下的text是存786B在row中,超過(guò)部分存在off-page 而服務(wù)器配置是 innodb_file_format = Barracuda 照理說(shuō)所有table用的都是 dynamic 結(jié)構(gòu)。 但是! 原因如下,摘自文檔: To preserve compatibility with those prior versions, tables created with the InnoDB Plugin use the prefix format, unless one of ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED is specified (or implied) on the CREATE TABLE command. 也就是說(shuō),建表時(shí)不顯示指定 row_format = dynamic ,即使 innodb_file_format = Barracuda 表的row-format還是 compact 所以總結(jié)為一句話就是:如果某個(gè)表的text字段很多建議建表時(shí)加上 row_format = dynamic 當(dāng)然,回過(guò)頭來(lái)MySQL的報(bào)錯(cuò)也是有誤導(dǎo)性的,bug庫(kù)中也對(duì)confirm了這個(gè)bug(點(diǎn)擊查看),并在5.1.61中優(yōu)化了報(bào)錯(cuò)提示。