是否有与 MySql 等效的 Profiler?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20263/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a Profiler equivalent for MySql?
提问by Andrew Rimmer
"Microsoft SQL Server Profiler is a graphical user interface to SQL Trace for monitoring an instance of the Database Engine or Analysis Services."
“Microsoft SQL Server Profiler 是 SQL 跟踪的图形用户界面,用于监视数据库引擎或分析服务的实例。”
I find using SQL Server Profiler extremely useful during development, testing and when I am debugging database application problems. Does anybody know if there is an equivalent program for MySql?
我发现在开发、测试和调试数据库应用程序问题时使用 SQL Server Profiler 非常有用。有人知道MySql是否有等效的程序吗?
采纳答案by Buggabill
Something cool that is in version 5.0.37 of the community server is MySQL's new profiler.
社区服务器 5.0.37 版中的一些很酷的东西是MySQL 的新分析器。
This may give you what info you are looking for.
这可能会为您提供您正在寻找的信息。
回答by Jon Topper
Are you wanting to monitor performance, or just see which queries are executing? If the latter, you can configure MySQL to log all queries it's given. On a RedHat Linux box, you might add
您是想监控性能,还是只想查看正在执行的查询?如果是后者,您可以配置 MySQL 以记录它给出的所有查询。在 RedHat Linux 机器上,您可以添加
log = /var/lib/mysql/query.log
log = /var/lib/mysql/query.log
to the [mysqld] section of /etc/my.cnf
before restarting MySQL.
/etc/my.cnf
在重新启动 MySQL 之前的 [mysqld] 部分。
Remember that in a busy database scenario, those logs can grow quite large.
请记住,在繁忙的数据库场景中,这些日志可能会变得非常大。
回答by Devid G
Try JET profiler is a real-time query performance and diagnostics tool! I use it in my work. Excellent software and support. Review Jet Profiler for MySQL
试用 JET profiler 是一款实时查询性能和诊断工具!我在工作中使用它。优秀的软件和支持。 查看 MySQL 的 Jet Profiler
回答by Victor Grados
Usin Neor Profiler SQL , is exelent!! and the application is free for all users. http://www.profilesql.com/download/
使用 Neor Profiler SQL ,非常好!!该应用程序对所有用户免费。http://www.profilesql.com/download/
回答by Matija
In my opinion I've found everything here in raw....
在我看来,我发现这里的一切都是原始的......
Find and open your MySQL configuration file, usually /etc/mysql/my.cnf on Ubuntu. Look for the section that says “Logging and Replication”
找到并打开你的 MySQL 配置文件,在 Ubuntu 上通常是 /etc/mysql/my.cnf。查找“日志记录和复制”部分
# * Logging and Replication
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
log = /var/log/mysql/mysql.log
or in newer versions of mysql, comment OUT this lines of codes
或在较新版本的 mysql 中,注释掉这行代码
general_log_file = /var/log/mysql/mysql.log
general_log = 1
log_error = /var/log/mysql/error.log
Just uncomment the “log” variable to turn on logging. Restart MySQL with this command: sudo /etc/init.d/mysql restart
只需取消注释“log”变量即可打开日志记录。使用此命令重新启动 MySQL: sudo /etc/init.d/mysql restart
Now we're ready to start monitoring the queries as they come in. Open up a new terminal and run this command to scroll the log file, adjusting the path if necessary.
现在我们准备开始监控进来的查询。打开一个新终端并运行此命令来滚动日志文件,如有必要调整路径。
tail -f /var/log/mysql/mysql.log
回答by Mauricio Alo
Not sure about graphical user interface but there is a command that has helped me profile stored procedures a lot in MySQL using workbench:
不确定图形用户界面,但有一个命令帮助我使用工作台在 MySQL 中分析了很多存储过程:
SET profiling = 1;
call your_procedure;
SHOW PROFILES;
SET profiling = 0;
回答by Ivan
Jet Profiler is good if it's a paid version. The LogMonitor just point it to the mysql log file.
如果是付费版本,Jet Profiler 是不错的选择。LogMonitor 只是将其指向 mysql 日志文件。
回答by Dave Marshall
回答by mercutio
I don't know about any profiling apps as such, but it's commonplace to use the EXPLAIN syntax for analysing queries. You can use these to figure out the best indexes to create, or you can try changing the overall query and see how it changes the efficiency, etc.
我不知道任何这样的分析应用程序,但使用 EXPLAIN 语法来分析查询是司空见惯的。您可以使用这些来找出要创建的最佳索引,或者您可以尝试更改整体查询并查看它如何改变效率等。