Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VARCHAR(200) is too long for innodb index length #933

Closed
javorszky opened this issue Aug 11, 2017 · 1 comment
Closed

VARCHAR(200) is too long for innodb index length #933

javorszky opened this issue Aug 11, 2017 · 1 comment

Comments

@javorszky
Copy link
Contributor

From https://dev.mysql.com/doc/refman/5.7/en/innodb-restrictions.html:

If innodb_large_prefix is enabled (the default), the index key prefix limit is 3072 bytes for InnoDB tables that use DYNAMIC or COMPRESSED row format. If innodb_large_prefix is disabled, the index key prefix limit is 767 bytes for tables of any row format.

innodb_large_prefix is deprecated and will be removed in a future release. innodb_large_prefix was introduced in MySQL 5.5 to disable large index key prefixes for compatibility with earlier versions of InnoDB that do not support large index key prefixes.

The index key prefix length limit is 767 bytes for InnoDB tables that use the REDUNDANT or COMPACT row format. For example, you might hit this limit with a column prefix index of more than 255 characters on a TEXT or VARCHAR column, assuming a utf8mb3 character set and the maximum of 3 bytes for each character.

Attempting to use an index key prefix length that exceeds the limit returns an error. To avoid such errors in replication configurations, avoid enabling innodb_large_prefix on the master if it cannot also be enabled on slaves.

The limits that apply to index key prefixes also apply to full-column index keys.

The column length need not changed, only the index length. PR incoming.

@brichards
Copy link

brichards commented Aug 11, 2017

Additional context:

Stream fails to install properly (sometimes) citing the following error:

WordPress database error Index column size too large. The maximum column size is 767 bytes. for query CREATE TABLE wp_stream_meta [...]

Some of my research on this shows that the issue is the utf8mb4 charset:

indeed WP core now limits indexes to 191 characters since the move to utf8mb4
(found in humanmade/Mercator#68 (comment))

The solution employed by Mercator was to reduce the varchar length for the indexed column (https://github.com/humanmade/Mercator/pull/89/files#diff-cc189074cc28f219c44992127f6a7731R199).

@javorszky's supplied PR resolves this issue in the Pantheon env where I was testing and first discovered it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants