why innodb index length limit to 3072 when page_size is 16k?

Viewed 32

why innodb index length limit to 3072 when page_size = 16k?

same questions with page_size 4kb and 8kb.

I searched and tried to find out from the source code, but I didn’t find the answer.

index length limits

1 Answers

https://github.com/mysql/mysql-server/blob/8.0/storage/innobase/handler/ha_innodb.cc#L6380-L6401 says:

An InnoDB page must store >= 2 keys; a secondary key record must also contain the primary key value. Therefore, if both the primary key and the secondary key are at this maximum length, it must be less than 1/4th of the free space on a page including record overhead.

MySQL imposes its own limit to this number; MAX_KEY_LENGTH = 3072.

For page sizes = 16k, InnoDB historically reported 3500 bytes here, But the MySQL limit of 3072 was always used through the handler interface.

https://github.com/mysql/mysql-server/blob/8.0/sql/sql_const.h#L47 says:

constexpr const unsigned int MAX_KEY_LENGTH{3072}; /* max possible key */

There is no comment to explain why this number is used. Perhaps other storage engines besides InnoDB are limited to 3072?

Related