MySQL ENUM option values impact max row size?
I am experimenting with MySQL enum data type. I have a table 15 columns of which 7 are ENUM data types. No VARCHARs, max column - type DATETIME. So I should be well within the 65535 bytes limit in mysql. Even within the 1000 bytes limit for InnoDB.
The ENUM types have a lot of big string possibilities (ranging in 1000s for 2 columns). I just altered the table to add more ENUM values to a table
ALTER TABLE <tablename> MODIFY <enumCol> ([...1000 values each of max 40 bytes]);
and got this error after that-
ERROR 1117 (HY000): Too many columns
I researched this and found that this error is related to the Max row size for MySql tables. Also, I read here http://dev.mysql.com/doc/refman/5.1/en/column-count-limit.html that -
开发者_如何学CEach 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
Are these ENUM value types getting stored here by any chance and this triggering the error( making the .frm file > 64K)? Or is something completely else going on?
According to the MySQL documentation, an ENUM
column should only take 1 to 2 bytes of storage depending on the amount of options you have in your enumeration. So its impact should be minimum on the row size.
However, if you have very long string as possible enum values, it won't affect your row size (since only the index is stored in the row, not the actual string value), but might go above the 64KB limit of the table definition file.
精彩评论