我有一张桌子,里面有300列.每列最多255个字节(这有一个商业理由).
当我尝试使用VARCHAR(255)创建它时,我超过了最大字节数的限制.所以我创建的是使用300个TEXT字段.当我尝试插入数据时,我收到错误:
Row size too large (> 8126).
Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help.
In current row format, BLOB prefix of 768 bytes is stored inline.
阅读完之后,我尝试通过指定ROW_FORMAT = COMPRESSED来更改表以使用Barracuda格式.现在的问题似乎是当我尝试使用该格式创建表时,我得到了同样的错误.
CREATE TABLE T_ObjLarge__c (Id VARCHAR(18), Name VARCHAR(80),
ObjLarge_Field_1__c TEXT,
ObjLarge_Field_2__c TEXT,
...
ObjLarge_Field_300__c TEXT
) ROW_FORMAT=COMPRESSED ;
我得到的错误是:
Row size too large (> 8126).
Changing some columns to TEXT or BLOB may help.
In current row format, BLOB prefix of 0 bytes is stored inline.
我在Linux薄荷上使用MySQL 5.5.31.没有索引.我试过DYNAMIC格式;它的行为方式相同.
输出SHOW GLOBAL VARIABLES LIKE’innodb_file_per_table’;:
+--------------------------+-----------+
| Variable_name | Value |
+--------------------------+-----------+
| innodb_file_format | Barracuda |
| innodb_file_format_check | ON |
| innodb_file_format_max | Barracuda |
| innodb_file_per_table | ON |
+--------------------------+-----------+
解决方法:
这是一个非常棘手的问题,因为你超越了InnoDB的当前限制.
你的问题绝不是唯一的.这已在此处讨论过
我还会查看您当前使用的字符集.
Bill Karwin在他的最后一段中说得最好
I also have to comment that I’ve never seen a well-designed table exceed the row size limit. It’s a strong “code smell” that you’re violating the repeating groups condition of First Normal Form.
您将不得不定义更好的设计.没有商业理由可以证明这一点.为什么?
我亲眼目睹了这一点
In my earlier days as a developer, I worked at a company back in 1995 where DB2 was the main RDBMS. The company had a single table that had 270 columns, dozens of indexes, and had performance issues retrieving data. They contacted IBM and had consultants look over the architecture of their system, including this one monolithic table. The company was told “If you do not normalize this table in the next 2 years, DB2 will fail on queries doing Stage2 Processing (any queries requiring sorting on non-indexed columns).” This was told to a multi-trillion dollar company, to normalize a 270 column table. How much more so a 2000 column table.
一个包含300个TEXT列的表要求同样的麻烦.
总结:Bill Karwin之前说过,我同意:重新设计表格.这肯定会限制行长度问题.
标签:linux,mysql,innodb,mysql-5-5
来源: https://codeday.me/bug/20190805/1592920.html