2

How do you fix the notorious "Row size too large" error that MySQL emits when you're using Django?

I have a query that I'm appending multiple tables to using Django's select_related(), and if I output the SQL query Django generates, and run that manually in a MySQL shell, it runs fine, but when Django tries to execute it and iterate over the records, Django throws the 500 error:

Warning: 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.

How do I fix this? Since it's just a "warning", can I instruct Django to ignore it?

I've tried the numerous fixes on the MySQL side, such as enabling Innodb with Barracuda format and table compression, but that's had no effect.

I've also tried reducing the number of tables included in my select_related(), but that's also had no effect, unless I remove practically everything from it.

I suspect that a temp table is being created, and that table either is not using Barracuda format and/or has so many rows that it's exceeding the max row size, even in Barracuda. I'm guessing it may be the former, since the query runs fine from a MySQL shell. Is there any way to fix this without removing my select_related()?

Cerin
  • 60,957
  • 96
  • 316
  • 522
  • Have you found a solution ? –  Jun 13 '17 at 20:37
  • Does this answer your question? [MySQL Error 1118 (Row size too large) when restoring Django-mailer database](https://stackoverflow.com/questions/25299370/mysql-error-1118-row-size-too-large-when-restoring-django-mailer-database) – Herbert Poul Apr 30 '20 at 08:11

1 Answers1

0

This problem happened with my django project either. I had to write logger or "print" to do debug, and of course I can't create unit test cases for my project. I know this issue is cause by my table setting, however with out a detailed fail log, to told me with statement cause the error, I can't make my unit test work. Hope somebody could help. If there could be a debug mode for python manage.py test .