Mysql如何确定哪些表和查询没有有效地使用索引?
Mysql如何确定哪些表和查询没有有效地使用索引?
有几个选项可以做到这一点:
- Use the Slow Query Log.
- Use the Sys Schema.
- Use the Performance Schema directly.
Slow Query Log
慢速查询日志包括有关检查的行数和返回的行数的信息。这可用于查找为返回的行检查最多行的查询。
SET GLOBAL slow_query_log=1;
SET GLOBAL log_queries_not_using_indexes = 1,
SET GLOBAL long_query_time = 10000;