Home Database Mysql Tutorial mysql Key_buffer_size参数的设置_MySQL

mysql Key_buffer_size参数的设置_MySQL

Jun 01, 2016 pm 01:29 PM
mysql Influence database maximum

bitsCN.com

mysql Key_buffer_size参数的设置

 

在mysql数据库中,mysql key_buffer_size是对MyISAM表性能影响最大的一个参数,下面就将对mysql Key_buffer_size参数的设置进行详细介绍,供您参考  。

 

  下面一台以MyISAM为主要存储引擎服务器的配置:

mysql> show variables like key_buffer_size;+-----------------+------------+| Variable_name | Value |+-----------------+------------+| key_buffer_size | 536870912 |+-----------------+------------+分配了512MB内存给mysql key_buffer_size,我们再看一下key_buffer_size的使用情况:mysql> show global status like key_read%;+------------------------+-------------+| Variable_name | Value |+------------------------+-------------+| Key_read_requests | 27813678764 || Key_reads | 6798830 |+------------------------+-------------+
Copy after login

一共有27813678764个索引读取请求,有6798830个请求在内存中没有找到直接从硬盘读取索引,计算索引未命中缓存的概率:

 

 key_cache_miss_rate = Key_reads / Key_read_requests * 100%
Copy after login

  比如上面的数据,key_cache_miss_rate为0.0244%,4000个索引读取请求才有一个直接读硬盘,已经很BT 了,key_cache_miss_rate在0.1%以下都很好(每1000个请求有一个直接读硬盘),如果key_cache_miss_rate在 0.01%以下的话,key_buffer_size分配的过多,可以适当减少 。

MySQL服务器还提供了key_blocks_*参数:

mysql> show global status like key_blocks_u%;+------------------------+-------------+| Variable_name | Value |+------------------------+-------------+| Key_blocks_unused | 0 || Key_blocks_used | 413543 |+------------------------+-------------+
Copy after login

Key_blocks_unused表示未使用的缓存簇(blocks)数,Key_blocks_used表示曾经用到的最大的blocks数,比如这台服务器,所有的缓存都用到了,要么增加key_buffer_size,要么就是过渡索引了,把缓存占满了 。比较理想的设置:

Key_blocks_used / (Key_blocks_unused + Key_blocks_used) * 100% ≈ 80%
Copy after login

 

 

bitsCN.com
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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to optimize MySQL query performance in PHP? How to optimize MySQL query performance in PHP? Jun 03, 2024 pm 08:11 PM

How to optimize MySQL query performance in PHP?

How to use MySQL backup and restore in PHP? How to use MySQL backup and restore in PHP? Jun 03, 2024 pm 12:19 PM

How to use MySQL backup and restore in PHP?

How to insert data into a MySQL table using PHP? How to insert data into a MySQL table using PHP? Jun 02, 2024 pm 02:26 PM

How to insert data into a MySQL table using PHP?

How to fix mysql_native_password not loaded errors on MySQL 8.4 How to fix mysql_native_password not loaded errors on MySQL 8.4 Dec 09, 2024 am 11:42 AM

How to fix mysql_native_password not loaded errors on MySQL 8.4

How to use MySQL stored procedures in PHP? How to use MySQL stored procedures in PHP? Jun 02, 2024 pm 02:13 PM

How to use MySQL stored procedures in PHP?

How to create a MySQL table using PHP? How to create a MySQL table using PHP? Jun 04, 2024 pm 01:57 PM

How to create a MySQL table using PHP?

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

Detailed tutorial on establishing a database connection using MySQLi in PHP

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos

See all articles