Skip navigation links
**Section Navigation** [Toggle]

MySQL Restrictions and Limitations :: 8 Limits in MySQL :: 8.5 Limits Imposed by .frm File Structure

- 8 Limits in MySQL
- 8.1 Limits of Joins
- 8.2 Limits on Number of Databases and Tables
- 8.3 Limits on Table Size
- 8.4 Limits on Table Column Count and Row Size
- 8.5 Limits Imposed by .frm File Structure
- 8.6 Windows Platform Limitations

Each table has an `.frm`

file that contains
the table definition. The server uses the following expression
to check some of the table information stored in the file
against an upper limit of 64KB:

if (info_length+(ulong) create_fields.elements*FCOMP+288+ n_length+int_length+com_length > 65535L || int_count > 255)

The portion of the information stored in the
`.frm`

file that is checked against the
expression cannot grow beyond the 64KB limit, so if the table
definition reaches this size, no more columns can be added.

The relevant factors in the expression are:

`info_length`

is space needed for “screens.” This is related to MySQL's Unireg heritage.`create_fields.elements`

is the number of columns.`FCOMP`

is 17.`n_length`

is the total length of all column names, including one byte per name as a separator.`int_length`

is related to the list of values for`ENUM`

and`SET`

columns. In this context, “int” does not mean “integer.” It means “interval,” a term that refers collectively to`ENUM`

and`SET`

columns.`com_length`

is the total length of column comments.

The expression just described has several implications for permitted table definitions:

Using long column names can reduce the maximum number of columns, as can the inclusion of

`ENUM`

or`SET`

columns, or use of column comments.A table can have no more than 255 unique

`ENUM`

and`SET`

definitions. Columns with identical element lists are considered the same against this limt. For example, if a table contains these two columns, they count as one (not two) toward this limit because the definitions are identical:e1 ENUM('a','b','c') e2 ENUM('a','b','c')

The sum of the length of element names in the unique

`ENUM`

and`SET`

definitions counts toward the 64KB limit, so although the theoretical limit on number of elements in a given`ENUM`

column is 65,535, the practical limit is less than 3000.

## User Comments

Documentation is at this time currently correct about com_length not including the table comment - see com_length in pack_header in sql/unireg.cc. In mysql-5.1.68 the relevant lines are 607 (set to 0), 638 (field->comment.length), 722 (the formula cited).

Also, while int_length is "related" to the list of values for ENUM and SET columns, the relationship is:

length of each string in each interval + 1 (for padding) + 2 * number of intervals (for terminal markers)

See lines 606 (set to 0), 704 (strlen+1), 711 (+= int_count*2), 723 (the formula cited).

info_length is (using integer or truncating division): (((create_fields.elements - 1)/19)+1)*48 as best I can tell - see pack_screens in sql/unireg.cc - note that pos is incremented by 4+(cols>>1)+4 each time row == end_row, which loops from [4,22], for a loop size of 19 (4..22 inclusive, due to the post increment). Since cols is fixed at 80, cols>>1 is 40, and the total increment is 48. Because we can, we assume small_file is true. Since row starts at end_row, we subtract one before the divisor and add it back afterwards - we might also simply add 18 to create_fields.elements similar to elsewhere in the documentation (adding 7 before dividing by 8).