mysql - Reset performance of all queries in mysql 8
问题描述
I am working with MySQL 8 for learning purposes. I created a covering index for a query that significantly increased its speed. Now I dropped that index and restarted my computer, but it seems like the query performance remained more or less the same. Is there any way to reset the state of MySql 8.0, so that I can test again all my queries as if they are being run for the first time?
解决方案
Turn these OFF:
mysql> show variables like 'innodb_buffer_pool%at%';
+-------------------------------------+-------+
| Variable_name | Value |
+-------------------------------------+-------+
| innodb_buffer_pool_dump_at_shutdown | ON |
| innodb_buffer_pool_load_at_startup | ON |
+-------------------------------------+-------+
When they are ON, which might be the default for MySQL 8, the buffer_pool (InnoDB's main caching mechanism) is reloaded even after a reboot.
So, change your settings to have them off, then restart only mysqld
to get MySQL into a "cold" state.
I take a different approach... The important timing is what will happen in a "production" environment -- where the buffer_pool is actively used, not cleared. So, I prefer to run a query twice and use the second timing.
Also, it is wise to keep the Query cache off.
More things for your learning exercise:
推荐阅读
- ruby - bundler 安装了特定版本后,为什么 bundler 的版本没有改变?
- c# - 当 Windows 服务停止时,使用块中的 StreamWriter.WriteAsync 无法写入整个文件
- html - 不应该使用 50% 父宽度环绕的 Flex div
- linux - 在 Linux 中将 STDERR 重定向到来自 Perl 的文件
- laravel - 获取关系集合 groupBy 列且不为空
- php - 我的登录屏幕不工作,黑屏
- ruby-on-rails - Rails 路由约束问题/错误或功能?
- java - spring Kafka集成测试监听器不起作用
- ruby-on-rails - 如何使用 Rails+Nginx+Postgresql+DigitalOcean 访问远程数据库?
- .net - 如何在 Powershell 中将 dotnet 框架从核心更改为 .NET 框架