Fixing “Row size too large” in Magento’s Flat Product Index
Stores with many attributes can hit MySQL’s row size limit when Magento 1 builds the flat product table:
Product Flat Data index process unknown error: exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs'
Why it happens
Each text attribute becomes a 255-character column in the flat table, and with enough of them the total row size goes over 65,535 bytes.
The fix
Copy app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php into the local code pool and reduce the column length from 255 to 64 in two places:
$columns[$this->getAttributeCode()] = array( 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, 'length' => '64', 'unsigned' => false, 'nullable' => true, 'default' => null, 'extra' => null );
$columns[$this->getAttributeCode()] = array( 'type' => 'varchar(64)', 'unsigned' => false, 'is_null' => true, 'default' => null, 'extra' => null );
Also review which attributes really need Used in Product Listing enabled, since fewer flat columns is the cleaner long-term fix.
Heads up: this guide applies to Magento 1, which stopped receiving official security updates in June 2020. If your store still runs it, plan a move to Magento 2 or Adobe Commerce soon. We can help with the migration.
Stuck on something similar? Our Magento development team is happy to take a look.