Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How many parameters are involved in MySQL query cache

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

What this article shares to you is about how many parameters are involved in MySQL query cache, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Query cache mainly involves two parameters, query_cache_size is used to set the query cache (query cache) size of MySQL, and query_cache_type is used to set the type of query cache to be used

You can view specific usage with the following command:

Mysql > show global status like 'qcache%'

+-+ +

| | Variable_name | Value |

+-+ +

| | Qcache_free_blocks | 1 | |

| | Qcache_free_memory | 195024544 | |

| | Qcache_hits | 0 | |

| | Qcache_inserts | 3 | |

| | Qcache_lowmem_prunes | 0 | |

| | Qcache_not_cached | 121 | |

| | Qcache_queries_in_cache | 1 | |

| | Qcache_total_blocks | 4 |

+-+ +

8 rows in set (0.00 sec)

The relevant parameters are explained as follows:

Qcache_free_blocks: the number of adjacent memory blocks in the cache. A large number means there may be fragments. Flush query cache will defragment the cache to get a free block.

Qcache_free_memory: free memory in the cache.

Qcache_hits: how many hits? you can see the basic hit effect of query cache through this parameter.

Qcache_inserts: increases every time you insert a query, and the number of hits divided by the number of inserts is the miss rate.

Qcache_lowmem_prunes: how many query are cleaned out of the query cache due to insufficient memory. Through the combination of Qcache_lowmem_prunes and Qcache_free_memory parameters, you can

Know more clearly whether the memory size of query cache in the system is really sufficient, and whether query is swapped out very frequently because of insufficient memory.

Qcache_not_cached: the number of queries that are not suitable for caching, usually because they are not SELECT statements or use functions such as now ().

Qcache_queries_in_cache: the number of queries and responses currently cached.

Qcache_total_blocks: the number of blocks in the cache.

About the configuration of query_cache:

Mysql > show variables like 'query_cache%'

+-+ +

| | Variable_name | Value |

+-+ +

| | query_cache_limit | 1048576 | |

| | query_cache_min_res_unit | 4096 | |

| | query_cache_size | 195035136 | |

| | query_cache_type | ON |

| | query_cache_wlock_invalidate | OFF |

+-+ +

5 rows in set (0.00 sec)

Each field is explained as follows:

Query_cache_limit: queries that exceed this size will no longer be cached.

Query_cache_min_res_unit: the minimum value of the cache block.

Query_cache_size: cache size valu

Query_cache_type: cache type, which determines what kind of query to cache.

Query_cache_wlock_invalidate: indicates whether the read request should wait for write lock to release resources before querying or allowing direct query when other clients are writing to the MyISAM table.

Read the result from query cache. Default is FALSE.

Query cache fragmentation rate = Qcache_free_blocks/Qcache_total_blocks * 100%

Query cache utilization = (query_cache_size-Qcache_free_memory) / query_cache_size * 100%

The query cache utilization is below 25%, which means that the query_cache_size setting is too large and can be reduced appropriately.

Query cache hit ratio = (Qcache_hits-Qcache_inserts) / Qcache_hits * 100%

The above is the number of parameters involved in the MySQL query cache, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report