MySQL - 强制不使用缓存来测试查询速度

2021-11-20 00:00:00 mysql

我正在测试 MySQL 中某些查询的速度.数据库正在缓存这些查询,这让我在测试这些查询的速度时很难获得可靠的结果.

I'm testing the speed of some queries in MySQL. The database is caching these queries making it difficult for me to get reliable results when testing how fast these queries are.

有没有办法禁用查询的缓存?

Is there a way to disable caching for a query?

系统:Linux 虚拟主机上的 MySQL 4,我可以访问 PHPMyAdmin.

System: MySQL 4 on Linux webhosting, I have access to PHPMyAdmin.

谢谢

推荐答案

尝试使用 SQL_NO_CACHE (MySQL 5.7) 选项.(MySQL 5.6 用户点击这里)

Try using the SQL_NO_CACHE (MySQL 5.7) option in your query. (MySQL 5.6 users click HERE )

例如

SELECT SQL_NO_CACHE * FROM TABLE

这将停止 MySQL 缓存结果,但请注意其他操作系统和磁盘缓存也可能影响性能.这些更难解决.

This will stop MySQL caching the results, however be aware that other OS and disk caches may also impact performance. These are harder to get around.

相关文章