Home > Database > Mysql Tutorial > Can MySQL Indexes Handle VARCHAR Columns Longer Than 255 Characters?

Can MySQL Indexes Handle VARCHAR Columns Longer Than 255 Characters?

Susan Sarandon
Release: 2024-11-30 04:02:11
Original
425 people have browsed it

Can MySQL Indexes Handle VARCHAR Columns Longer Than 255 Characters?

Can MySQL index more than 255 characters of a VARCHAR column?

In MySQL versions prior to 8.0, the index size for a VARCHAR column in the utf8 character set was limited to 255 characters. This was because MySQL assumed that each UTF-8 character would require 3 bytes of storage space, and the maximum index size for a single column was 767 bytes.

However, starting with MySQL 8.0, the maximum index size for a VARCHAR column in the utf8 character set has been increased to 3072 bytes when using the COMPRESSED or DYNAMIC row format. This allows you to index up to 1024 characters in a VARCHAR column.

When using the utf8mb4 character set, the maximum index size for a VARCHAR column is 191 characters with the COMPACT or REDUNDANT row format, or 768 characters with the COMPRESSED or DYNAMIC row format.

Please note that these are just general guidelines. The actual maximum index size for a specific column may vary depending on the number of columns in the index, the length of the other columns, and the character set and row format used.

The above is the detailed content of Can MySQL Indexes Handle VARCHAR Columns Longer Than 255 Characters?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template