In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
How to query cache in MySQL? for this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
You can view the current query cache related parameter status through the following SQL: the output result of SHOW VARIABLES LIKE'% query_cache%'; is similar to the following:
Query_cache_type query cache type, with values of 0, 1, and 2. 0 does not use query caching. 1 means that query caching is always used. 2 means to use query caching on demand. If the query_cache_type is 1 and you do not want to use the data in the query cache, you can use the following SQL: SELECT SQL_NO_CACHE * FROM my_table WHERE condition; if the value is 2, to use the cache, you need to use the SQL_CACHE switch parameter: SELECT SQL_CACHE * FROM my_table WHERE condition Query_cache_size default query_cache_size is 0, indicating that the memory reserved for the query cache is 0, then the query cache cannot be used. So we need to set the value of query_cache_size: SET GLOBAL query_cache_size = 134217728; note that the above value will not take effect if it is set too low. For example, I set the query_cache_size size with the following SQL: SET GLOBAL query_cache_size = 4000; SHOW WARNINGS; returns the following result:
The cache condition query cache can be thought of as a mapping of SQL text and query results. If the SQL of the second query is exactly the same as the SQL of the first query (note that it must be exactly the same, even if one more space or different case is considered to be different) and the query cache is turned on, then the second query fetches the result directly from the query cache. You can view the cache hits (a cumulative value) through the following SQL: SHOW STATUS LIKE 'Qcache_hits' In addition, even if the exact same SQL, if you use different character sets, different protocols, etc., will be regarded as different queries and cached separately. When the cache data expires, when the structure or data of the table changes, the data in the query cache is no longer valid. Having these INSERT, UPDATE, DELETE, TRUNCATE, ALTER TABLE, DROP TABLE, or DROP DATABASE can cause cached data to invalidate. Therefore, query cache is suitable for applications with a large number of the same queries, but not for applications with a large number of data updates. To clean up the query cache, you can use the following three SQL to clean up the query cache: the first SQL of 1.FLUSH QUERY_CACHE; 2.RESET QUERY_CACHE; 3.FLUSH TABLES; cleans up the memory fragments of the query cache. The second SQL removes all queries from the query cache. The third SQL closes all open tables, and the operation clears the contents of the query cache.
This is the answer to the question about how to query cache in MySQL. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.