MySQL table_cache optimization (III)

Source: Internet
Author: User

Current configuration problem found (mysql + linux Online System)
Show global status like open % tables %;
+ --------------- + ------- +
| Variable_name | Value |
+ --------------- + ------- +
| Open_tables | 966 |
| Opened_table | 2919 |
+ --------------- + ------- +
2 rows in set
Based on these days of painstaking research (The following is the relevant knowledge)
Table_cache indicates the table cache size. When Mysql accesses a table, if there is still space in the Mysql table buffer, the table will be opened and put into the table buffer, in this way, you can access the content in the table more quickly. In general, you can check the status values Open_tables and Opened_tables of the database peak time to determine whether to increase the value of table_cache.
Show global status like open % tables %; view opened tables
Open_tables indicates the number of opened tables, and Opened_tables indicates the number of opened tables. If the number of Opened_tables is too large, the value of table_cache (table_cache after 5.1.3) in the configuration may be too small.
Applicable values:
Open_tables/Opened_tables * 100%> = 85%
Open_tables/table_cache * 100% <= 95%
Currently, I have set table_cache = 1024 for this online db.
This causes a problem.
966/2919 is only 33%, which is obviously problematic. (This system is where the host obtains data from the host)
How can I set this value table_cache = ??

--------------------------------------------------------------------------------
Parameter Optimization is based on the premise that InnoDB tables are generally used in our databases, rather than MyISAM tables. When optimizing MySQL, two configuration parameters are the most important, table_cache and key_buffer_size.
Table_cache
Table_cache specifies the table cache size. When MySQL accesses a table, if there is space in the table buffer, the table is opened and put into it, so that the table content can be accessed more quickly. Check the status values Open_tables and Opened_tables of the peak time to determine whether to increase the value of table_cache. If you find that open_tables is equal to table_cache and opened_tables is growing, you need to increase the value of table_cache (the preceding STATUS values can be obtained using show status like 'open % tables ). Note that you cannot blindly set table_cache to a large value. If it is set too high, the file descriptor may be insufficient, resulting in unstable performance or connection loss.
Table_cache-64
Open_tables-64
Opened-tables-431
Uptime-1662790 (measured in seconds)
Although open_tables is already equal to table_cache, opened_tables has a very low value compared to the server running time. Therefore, increasing the value of table_cache should be of little use.
There is no need to modify the materials found.

--------------------------------------------------------------------------------
Mysql> show status like key_read %;
+ ------------------- + ------------ +
| Variable_name | Value |
+ ------------------- + ------------ +
| Key_read_requests | 1430416782 |
| Key_reads | 269031 |
+ ------------------- + ------------ +
2 rows in set
[3:42:39] bruce: the formula for the total memory requirement is global buffer + connections * buffer per connection.
Global buffer includes: key_buffer_size & innodb_buffer_size
Buffer per connection: generally 4 m (worst case), including read_buffer, sort_buffer, thread stack, and so on.
[3:47:04] bruce: key_buffer_size only applies to the MyISAM table,
Key_buffer_size specifies the size of the index buffer, which determines the index processing speed, especially the index reading speed. Generally, we set the value to 16 M. In fact, the number of sites that are slightly larger is far from enough. By checking the status values Key_read_requests and Key_reads, we can check whether the key_buffer_size setting is reasonable. The ratio of key_reads/key_read_requests should be as low as possible, at least and (the above STATUS values can be obtained using show status like 'key _ read % ). Or if you have installed phpmyadmin, you can see it through the server running status. I recommend you use phpmyadmin to manage mysql. The following status values are all my instance analysis obtained through phpmyadmin:
This server has been running for 20 days
 
Key _buffer_size-128 M
Key_read_requests-650759289
Key_read-79112

Related Article

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.