Issue with maximum row size in MySQL

I have a problem with MySQL, I have a table with many text fields. When I try to store some data I obtain this error.

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

The text that I store in each field is not too long, only a few paragraphs in each one.

What can I do?


Thanks for the people that answer. The links you posted were a very useful base to start learning.

Finally I found this page: http://download.oracle.com/docs/cd/E17952_01/refman-5.5-en/innodb-compression-usage.html

And I configured my.cnf adding these two lines in [mysqld] section:

innodb_file_per_table
innodb_file_format = Barracuda

Then I ALTER my table with this command through phpMyAdmin:

ALTER TABLE nombre_tabla
 ENGINE=InnoDB
 ROW_FORMAT=COMPRESSED 
 KEY_BLOCK_SIZE=8; 
 SHOW WARNINGS;

It is also possible use other settings that you can read in the link above, but these worked good for me.


You may want to take a look at this article which explains a lot about MySQL row sizes. It's important to note that even if you use TEXT or BLOB fields, your row size could still be over 8K (limit for InnoDB) because it stores the first 768 bytes for each field inline in the page. The simplest way to fix this is to use the Barracuda file format with InnoDB. This basically gets rid of the problem altogether by only storing the 20 byte pointer to the text data instead of storing the firs 768 bytes.


Well, do as mysql says: convert big fields from varchar to text or blob (ALTER TABLE). text fields behave much like varchar (indices needs prefix length, but nevertheless work), but are stored separately.

This reference tells you the exact limits of every stock mysql table engine:

http://dev.mysql.com/doc/refman/5.0/en/column-count-limit.html

And here's everything to know about text fields:

http://dev.mysql.com/doc/refman/5.0/en/blob.html