char/varchar-length in bytes or characters?

On some board, I read that *char differs from *text in that the first one measures the length of in characters, and the second one in bytes. That is, logically, char(255) will write a string in Cyrillic to unicode is all 255 characters, and text(255) should trim it to about half.

So here's the question: how many actual bytes will be allocated for fixed-type storage char(10) compared to utf8_general_ci? Where to find the truth?

the table has grown to millions of records, queries run indecently long, looking for ways to increase performance. Also, I learned that it turns out that if there is at least one variable-length field in the table, all fields char are automatically converted to varchar

Author: kanaris, 2016-03-14

1 answers

Characters. Char, varchar, enum, text, and others are limited in length in characters. But general limits (for example, on the length of a row in a table, or the size of an index), can be additionally limited in bytes from above.

The direct text says in the manual:

For example, MySQL must reserve 30 bytes for a CHAR(10) CHARACTER SET utf8 column.

Char (10) in utf8_general_ci will take 30 bytes regardless of the written data.

 7
Author: Мелкий, 2016-03-14 13:50:00