I found a post on the Percona blog that says: 对于MySQL缓存,您可以重新启动MySQL,这是清除所有缓存的唯一方法.您可以执行FLUSH TABLES来清除MySQL表缓存(但不能清除Innodb表元数据),也可以执行设置全局key_buffer_size = 0;将global key_buffer_size = DEFAULT设置为零密钥缓冲区,但是无法在不重新启动的情况下清理Innodb缓冲池. For MySQL Caches you can restart MySQL and this is the only way to clean all of the caches. You can do FLUSH TABLES to clean MySQL table cache (but not Innodb table meta data) or you can do "set global key_buffer_size=0; set global key_buffer_size=DEFAULT" to zero out key buffer but there is no way to clean Innodb Buffer Pool without restart.在评论中他继续说: 实际上,所有内容都有缓存.要进行真实的性能分析,您需要分析真实的查询组合,这将使每个具有适当缓存/命中率的查询不在循环中运行一个查询,并假设结果会很好. Practically everything has caches. To do real profiling you need to profile real query mix which will have each query having appropriate cache/hit ratio not running one query in the loop and assuming results will be fine.我想总结一下.确实很难测试单个查询.我的情况是我想尝试强制使用不同的索引,以确保查询计划程序选择正确的索引,而且显然,我必须在两次测试之间重新启动MySQL,才能消除缓存!I guess that sums it up. It does make it hard to test individual queries. My case is that I want to try forcing different indices to make sure the query planner is picking the right one, and apparently I'll have to restart MySQL between tests to take the cache out of the equation! 这篇关于刷新InnoDB缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!