以下的文章主要向大家描述的是MySQL 查询缓存的实际操作步骤以及对MySQL 查询缓存的二十几应用代码的描述,以下就是对查询缓存的的大小查看以及监视其相关性能这些相关内容的描述。
MySQL>select@@query_cache_type; +--------------------+ |@@query_cache_type| +--------------------+ |ON| +--------------------+ MySQL>setquery_cache_type=off; MySQL>setquery_cache_type=on; MySQL> MySQL>selectsql_cacheid,title,bodyfromarticle; MySQL>selectsql_no_cacheid,title,bodyfromarticle; MySQL>showvariableslike'have_query_cache'; +------------------+-------+ |Variable_name|Value| +------------------+-------+ |have_query_cache|YES| +------------------+-------+ 1rowinset(0.00sec)
查看MySQL 查询缓存的大小
MySQL>select@@global.query_cache_size; +---------------------------+ |@@global.query_cache_size| +---------------------------+ |16777216| +---------------------------+ 1rowinset(0.00sec) MySQL>select@@query_cache_size; +--------------------+ |@@query_cache_size| +--------------------+ |16777216| +--------------------+ 1rowinset(0.00sec)
查看***缓存结果,如果结果集大于该数,不缓存。
MySQL>select@@global.query_cache_limit; +----------------------------+ |@@global.query_cache_limit| +----------------------------+ |1048576| +----------------------------+ 1rowinset(0.00sec)
碎片整理
MySQL>flushquerycache ->; QueryOK,0rowsaffected(0.00sec)
清除缓存
MySQL>resetquerycache ->; QueryOK,0rowsaffected(0.00sec)
监视MySQL 查询缓存性能:
MySQL>flushtables; QueryOK,0rowsaffected(0.04sec) MySQL>showstatuslike'qcache%'; +-------------------------+----------+ |Variable_name|Value| +-------------------------+----------+ |Qcache_free_blocks|1| |Qcache_free_memory|16768408| |Qcache_hits|6| |Qcache_inserts|36| |Qcache_lowmem_prunes|0| |Qcache_not_cached|86| |Qcache_queries_in_cache|0| |Qcache_total_blocks|1| +-------------------------+----------+ 8rowsinset(0.06sec)
看看当前缓存中有多少条信息:
MySQL>showstatuslike'qcache_q%'; +-------------------------+-------+ |Variable_name|Value| +-------------------------+-------+ |Qcache_queries_in_cache|0| +-------------------------+-------+ 1rowinset(0.00sec) MySQL>selectsql_cacheid,title,bodyfromarticle; MySQL>showstatuslike'qcache_q%'; +-------------------------+-------+ |Variable_name|Value| +-------------------------+-------+ |Qcache_queries_in_cache|1| +-------------------------+-------+ 1rowinset(0.00sec) MySQL>showstatuslike'qcache_f%'; +--------------------+----------+ |Variable_name|Value| +--------------------+----------+ |Qcache_free_blocks|1| |Qcache_free_memory|16766728| +--------------------+----------+ 2rowsinset(0.00sec)
以上的相关内容就是对MySQL 查询缓存的介绍,望你能有所收获。
【编辑推荐】
- 解决MySQL无法远程访问的3方案甲骨文对MySQL数据库做出十大承诺!解决MySQL远程访问不允许得个好用方案MySQL 常用语句的基本用法的介绍安装MySQL-python的实际操作步骤