Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL: What is the key buffer

Tags:

I'm trying to tweak my MySQL server to fit my needs... and I have a basic question: What is the key buffer?

Through try and error I've found that a bigger key buffer makes my inserts faster... but I don't quite understand what it is. So... before I make something I might regret, I'd like to know what it is, and how it works.

The script I'm running (MyISAM tables) is making about 2000 inserts per second.

(My server setup is Intel i7, 8GB RAM, CentOS 5.5, MySQL Server 5.0.)

like image 370
Barranka Avatar asked Sep 07 '10 23:09

Barranka


People also ask

What is key buffer size MySQL?

By default, MySQL will only use 8MB for MyISAM's key buffer and 8MB for InnoDB's buffer pool. Therefore, databases of any significant size will need these configurations tuned. The upper limit is determined in part by your operating system process limits, and how much memory is available with your system's hardware.

What is InnoDB buffer in MySQL?

What is an InnoDB Buffer Pool? InnoDB buffer pool is the memory space that holds many in-memory data structures of InnoDB, buffers, caches, indexes and even row-data. innodb_buffer_pool_size is the MySQL configuration parameter that specifies the amount of memory allocated to the InnoDB buffer pool by MySQL.

What does buffer pool do?

The buffer pool is an area in main memory where InnoDB caches table and index data as it is accessed. The buffer pool permits frequently used data to be accessed directly from memory, which speeds up processing.


1 Answers

What is the Key Buffer?

The key buffer is MyISAM specific, a structure for index blocks that contains a number of block buffers where the most-used index blocks are placed. It's mean for minimizing disk I/O, because memory is still faster than hard drives [currently]. The MyISAM key buffer is described in more detail in the documentation.

Guidelines for Tuning the Key Buffer

Size depends on amount of indexes, data size and workload.

  • Set up to 30-40% of available memory if you use MyISAM tables exclusively. 2-4 MB minimum; dedicating GBs can be a waste.

For more info, see this article on MySQL tuning.

like image 135
OMG Ponies Avatar answered Sep 30 '22 17:09

OMG Ponies