Incident Response

MySQL ERROR 1118: Row size too large (> 8126)

One error number, two different limits. How to tell the InnoDB page limit from the 65,535-byte server limit, why DYNAMIC fixes one case and not the other, and how to change row formats and column types on large tables.

· 15 min read · AG Data Team

MySQL ERROR 1118: Row size too large appears when a table definition, or a single row, does not fit one of two limits: the InnoDB limit of roughly half a page (the familiar > 8126) or the server-wide limit of 65,535 bytes. They share an error number but need different fixes, so start by reading which one you got.

-- InnoDB page limit
ERROR 1118 (42000): 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.

-- MySQL server limit
ERROR 1118 (42000): Row size too large. The maximum row size for the used table type,
not counting BLOBs, is 65535. This includes storage overhead, check the manual.
You have to change some columns to TEXT or BLOBs

The server error reference lists 1118 as ER_TOO_BIG_ROWSIZE, SQLSTATE 42000. The text with 65535 is the server limit. The text with > 8126 comes from InnoDB, and its last sentence tells you the row format: a 768-byte BLOB prefix means COMPACT or REDUNDANT, a 0-byte prefix means DYNAMIC.

Limit 1: 65,535 bytes for the whole row

The MySQL manual is blunt: the internal representation of a table has a maximum row size of 65,535 bytes, whatever the storage engine can do. Every column counts with its maximum byte length plus length bytes. A VARCHAR(10000) in utf8mb4 reserves up to 40,000 bytes, because one character can take four bytes, so two such columns are already too many. TEXT and BLOB columns contribute only 9 to 12 bytes, because their contents are stored separately.

The fix for this variant is always the same: turn the largest VARCHAR columns into TEXT (or VARBINARY into BLOB), or shrink their declared length to what the data actually needs. Changing the row format does nothing here.

Limit 2: about half an InnoDB page

InnoDB keeps rows in B-tree pages. The InnoDB limits page puts the maximum row size, not counting variable-length columns stored off-page, at slightly less than half a page for 4KB to 32KB pages. With the default 16KB innodb_page_size that is the 8126 bytes in the message. When a row is longer, InnoDB moves variable-length columns to overflow pages until the rest fits. How much stays behind depends on the row format:

The trap: short columns cannot leave the page

Off-page storage only helps if InnoDB is allowed to move the column. In the InnoDB source (data0type.h), a column qualifies as "big" when its maximum length is over 255 bytes or it is a BLOB-type column. A VARCHAR(50) in utf8mb4 has a maximum of 200 bytes, so it always stays in the row. The manual's own example is a DYNAMIC table with 33 CHAR(255) columns in latin1: CREATE TABLE fails with 1118, and the message says the BLOB prefix is 0 bytes. Dozens of short utf8mb4 VARCHAR columns run into the same wall.

This also explains a confusing pattern we see in production: the CREATE TABLE succeeds, the application runs for months, and then one INSERT or UPDATE fails with 1118. In our experience it is usually a row where many short columns are full at once, often with multibyte or emoji text, so the actual byte count crosses the limit that the column definitions only made possible.

What innodb_strict_mode changes

innodb_strict_mode is ON by default. With it, InnoDB runs a row size check during CREATE TABLE and ALTER TABLE and returns an error. With it off, the same table is created with a warning (code 139), and the error moves to the first INSERT or UPDATE that builds a row that is too large. Turning strict mode off is not a fix; it hides the problem until production data trips over it.

Two related situations produce the same error:

Fixing it, in order

  1. Check page size, strict mode and the table's row format.
    SELECT @@innodb_page_size, @@innodb_strict_mode, @@innodb_default_row_format;
    
    SELECT TABLE_NAME, ROW_FORMAT
    FROM information_schema.TABLES
    WHERE TABLE_SCHEMA = 'app' AND TABLE_NAME = 'customer_profile';
    
    SHOW CREATE TABLE app.customer_profile\G
  2. If the table is COMPACT or REDUNDANT, convert it to DYNAMIC. This is an in-place rebuild that allows concurrent reads and writes, and in most legacy cases it is the whole fix.
    ALTER TABLE app.customer_profile
      ROW_FORMAT = DYNAMIC, ALGORITHM = INPLACE, LOCK = NONE;
  3. If it is already DYNAMIC, change the columns. Turn long, rarely filtered columns into TEXT or BLOB, or move them into a one-to-one side table. Shrinking a declared length helps against the 65,535-byte limit, but a column that drops to 255 bytes or less can no longer move off-page.
  4. Re-check after charset changes. Converting from utf8mb3 to utf8mb4 raises the maximum byte length of every character column by a third, which is a common way to cross both limits. The ERROR 1366 Incorrect string value guide covers the charset side.
  5. Do not reach for innodb_page_size. It can only be set before the instance is initialised. Changing it means a new instance and a full logical reload, which is rarely worth it for one wide table.

The 768-byte prefix is the giveaway. If the message ends with "BLOB prefix of 768 bytes is stored inline", the table is not DYNAMIC. Convert the row format first; only redesign columns if the error survives the conversion.

On large tables

On a small table each of these changes takes seconds. On a table with hundreds of gigabytes, each is a full rebuild, and the details decide whether it is a quiet maintenance task or an incident.

-- tables still on the old formats
SELECT TABLE_SCHEMA, TABLE_NAME, ROW_FORMAT,
       ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS size_mb
FROM information_schema.TABLES
WHERE ENGINE = 'InnoDB'
  AND ROW_FORMAT IN ('Compact', 'Redundant')
ORDER BY size_mb DESC;
-- changing a column type is COPY only: writes are blocked for the whole rebuild
ALTER TABLE app.customer_profile
  MODIFY notes TEXT, ALGORITHM = COPY;
-- the widest rows by bytes stored in short columns (full scan: run it on a replica)
SELECT id,
       COALESCE(LENGTH(first_name), 0) + COALESCE(LENGTH(last_name), 0)
     + COALESCE(LENGTH(city), 0)       + COALESCE(LENGTH(street), 0) AS bytes
FROM app.customer_profile
ORDER BY bytes DESC
LIMIT 20;

Moving columns off-page fixes the error but is not free. Each off-page value is another page read when the query needs it. In our experience the best long-term shape for very wide tables is a narrow main table with the hot columns and a side table for large or optional fields, so that the common queries never touch the overflow pages.

Key takeaways

MySQL Errors InnoDB Schema design
Work with us

Wide tables hitting row size limits?

We audit MySQL schemas for row size risks, convert row formats and column types on large tables without downtime and plan the change across replicas.

Get in touch More from the blog