What is key_buffer_size in MySQL?

Roman Agabekov - Dec 30 '22 - - Dev Community

Image description1️⃣ Description
The key_buffer_size variable, also called the key cache, sets the buffer size for index blocks.

2️⃣ Usage
The key_buffer_size variable is used with the MyISAM storage engine in earlier versions of MySQL.

When key_buffer_size is increased, more memory is allocated for the MySQL index buffer. More memory means less reliance on disk I/O and improved performance. For server situations still using MyISAM, set this value at 25 to 30% of available memory.

3️⃣ Configuration
key_buffer_size system variable can be configured using:

  • the command line
  • configuration file

4️⃣ Recommendations
When configuring the key_buffer_size variable, try to keep this value between 25% and 30% of the server's total memory. Be careful not to raise key_buffer_size too high (above 50%), or you will experience significant slowdowns due to paging.

Ideally, keep the ratio between key_reads to key_read_requests as low as possible. This means that for every key_read from the disk, there are way more key_read_requests from memory.

The original article is in the first comment.

. . . . . . . . . . . . . . . . . . . . . . . . . . . .