Mysql optimization tips (key_buffer_size setting)

Source: Internet
Author: User

Mysql optimization tips (key_buffer_size settings) 1: For mysql, when logging on, add a parameter [SQL] # mysql-u root-p -- prompt = "\ u @ \ d \ r: \ m: \ s> "-- prompt adds some login parameters. The above parameter u is the username for logon, and d is the database table for use dbname after logon, r m s is time 2: key_buffer_size has a great impact on the performance of MyISAM tables. [SQL] mysql> show variables like 'key _ buffer_size '; + ----------------- + ------------ + | Variable_name | Value | + ----------------- + ---------- + | key_buffer_size | 536870912 | + ----------------- + ------------ + Allocated MB of memory to mysql key_buffer_size. Let's take a look at the usage of key_buffer_size: [SQL] mysql> show global status like 'key _ read % '; + bytes + ------------- + | Variable_name | Value | + ------------------------ + ------------- + | Key_read_requests | 27813678764 | Key_reads | 6798830 | + bytes + ------------- + A total of 27813678764 index read requests, 6798830 requests are not found in the memory and are directly read from the hard disk. Reference: calculate the probability that the index does not hit the cache: key_cache_miss_rate = Key_reads/Key_read_requests * 100%. For example, if the above data is set to key_cache_miss_rate to 0.0244%, only one direct read hard disk is available for the first, the key_cache_miss_rate is very good at lower than 0.1% (each 1000 requests have a direct read hard disk). If the key_cache_miss_rate is less than 0.01%, too many key_buffer_size allocation can be reduced as appropriate. The MySQL server also provides the key_blocks _ * parameter: [SQL] mysql> show global status like 'key _ blocks_u % '; + buffers + ------------- + | Variable_name | Value | + cached + ------------- + | Key_blocks_unused | 0 | Key_blocks_used | 413543 | + cached + ------------- + cached indicates unused cache clusters (blocks) number, Key_blocks_used indicates the maximum number of blocks used in the past. For example, on this server, all the caches are used, either key_buffer_size is increased or the transitional index is used. The cache is full. Ideal settings: Key_blocks_used/(Key_blocks_unused + Key_blocks_used) * 100% ≈ 80%

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.