ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

MySQL:行大小太大(> 8126)

2019-08-05 22:52:25  阅读:420  来源: 互联网

标签:linux mysql innodb mysql-5-5


我有一张桌子,里面有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的当前限制.

你的问题绝不是唯一的.这已在此处讨论过

> By Me,2012年8月14日:error 1118: row size too large. utf8 innodb
>作者Bill Karwin,2011年10月6日:InnoDB create table error: “Row size too large”

我还会查看您当前使用的字符集.

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.

您将不得不定义更好的设计.没有商业理由可以证明这一点.为什么?

回到2011年7月20日,我回答了这个问题:Too many columns in MySQL

我亲眼目睹了这一点

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

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有