MySQL:帮助查找执行时间太长的查询

时间:2023-01-03 04:02:54

How to find the MySQL query which take too long to execute (more than 5 sec)?

如何找到执行时间过长(超过5秒)的MySQL查询?

I tried using PROCESSLIST but its showing minimum info. I need the full query currently running in the server so i can try optimizing the queries to decrease my server load.

我尝试使用PROCESSLIST但显示最小信息。我需要当前在服务器中运行的完整查询,以便我可以尝试优化查询以减少我的服务器负载。

Is there any terminal command available to find the currently processing query?

是否有任何终端命令可用于查找当前正在处理的查询?

1 个解决方案

#1


2  

If you are using MySQL 5.1+, the slow query log can be used. Here and here is documentation. The configuration and running options are related to MySQL version. But I believe you can achieve your goals following the instructions related to your environment.

如果您使用的是MySQL 5.1+,则可以使用慢查询日志。这里和这里是文档。配置和运行选项与MySQL版本相关。但我相信您可以按照与您的环境相关的说明实现您的目标。

#1


2  

If you are using MySQL 5.1+, the slow query log can be used. Here and here is documentation. The configuration and running options are related to MySQL version. But I believe you can achieve your goals following the instructions related to your environment.

如果您使用的是MySQL 5.1+,则可以使用慢查询日志。这里和这里是文档。配置和运行选项与MySQL版本相关。但我相信您可以按照与您的环境相关的说明实现您的目标。