MySQL optimization and mysql Optimization
1. cache pool
MySQL is designed to use a cache pool. That is to say, some data is stored in the memory. When we look for a data, if we find it in the cache pool, you can directly
Obtain from the cache. If not, load it to the disk. Therefore, we recommend that you use a 64-bit operating system for the database server to use a large memory. The following parameters are used to set the memory pool.
Of:
SHOW VARIABLES LIKE "innodb_buffer_pool_instances"
To view the number of cache pools, you can use globle or directly set them in the configuration file.
show VARIABLES like "innodb_buffer_pool_size"
View the size of each cache pool. The queried size is byte.
Note that this setting takes into account the capabilities of your server.
To verify the cache hit rate, you can pass
SHOW ENGINE INNODB STATUS
One row of output is very important. We can see that the hit rate is:
Buffer pool hit rate 1000 / 1000
Indicates the cache hit rate, which generally cannot be lower than 95%.
2. LRU list
Data is stored in the cache through LRU, that is, the latest data to be queried is placed at the beginning, that is, hotspot data, but this LRU algorithm has some variants, specifically each time
The queried data is not inserted to the first position, but inserted to the center. This position becomes the midpoint. The default position is 3/5, the reason for this is to prevent some table scan operations from
All the data is refreshed. Several parameters can be set.
SHOW VARIABLES LIKE "innodb_old_blocks_pct"
Indicates the position of the midpoint. The default value is:
About 3/5.
Another parameter is
SHOW VARIABLES LIKE "innodb_old_blocks_time"
That is, how long it takes for data to be inserted to the midpoint to take effect.
If hotspot data is concentrated in a real environment, you can set the LRU parameter to prevent hotspot data from being flushed out.
3. Index
Http://www.cnblogs.com/zr520/p/6405197.html