Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Here's the issue. I have a table which has 300 columns in it, each up to 255 bytes (there IS a business justification for this). When I try it create it using VARCHAR(255), I go past the limit for the maximum number of bytes. So I create is using 300 TEXT fields. When I then try and insert data, I get the error:

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.

After reading up on this, I tried to change the table to use Barracuda format by specifying ROW_FORMAT=COMPRESSED. The issue now seems to be that when I try and create the table using that format, I get the same error.

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 ;

The error I get is:

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.

Please help!

share|improve this question
3  
I would really like to a see the "justification" for a table with 300 TEXT columns. –  a_horse_with_no_name Jul 6 '13 at 22:06
    
What version of MySQL? –  ypercube Jul 6 '13 at 23:56
    
5.6 on Linux mint –  hamayoun Jul 7 '13 at 2:06
1  
You didn't mention having any indexes on the table. Are there indexes? If so, does the error occur if the indexes aren't defined? Have you tried the DYNAMIC format? Does it behave similarly? Also, please provide the full server version... 5.6.??? –  Michael - sqlbot Jul 7 '13 at 4:54
    
Are you using innodb_file_per_table? Please run SHOW GLOBAL VARIABLES LIKE 'innodb_file_per_table'; –  RolandoMySQLDBA Jul 7 '13 at 12:15

1 Answer 1

This is a very tough question to answer simply because you are going beyond InnoDB current limits.

Your question is not by any means unique. This has been addressed here before

I would also look into the character set you are currently using.

Bill Karwin said it best in his last paragraph

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.

You are going to have to define a better design. No business reason can ever justify it. Why?

Back on July 20, 2011, I answered this question: Too many columns in MySQL

I personally eyewitnessed this

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.

A table with 300 TEXT columns is asking for same kind of trouble.

SUMMARY : Bill Karwin said it before and I agree: REDESIGN THE TABLE. That will circvumvent the row length issue for sure.

share|improve this answer
    
I agree that the design isn't likely justifiable ... but the Barracuda format should permit this by not storing prefixes from TEXT or BLOB columns on-page. A TEXT column, according to the docs, should only require 10 bytes of space in the row, so 300 = 3000 bytes. Barring additional information from OP, I am inclined to think this is a bug or a case of the documentation being wrong or ambiguous. It also may be that this is only true for BLOB and not for TEXT though in most places the documentation leads me to believe they're treated comparably under Barracuda. –  Michael - sqlbot Jul 8 '13 at 3:34
    
Too curious for my own good, I replicated this. In MySQl 5.5.32, I can create a table with an INT PK plus up to 186 nullable TEXT or BLOB columns, but if I try to define 187 or more TEXT or BLOB columns, I get the same error as OP... further testing suggests that approx 43 row bytes (of the ~8126 available) are used for each TEXT column, which I'm at a loss to explain with any degree of certainty... but this does explain why the limit is being reached sooner than should be expected based on the docs. :( –  Michael - sqlbot Jul 8 '13 at 4:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.