问题描述
我正在使用mysql命令在Linux主机上工作.我有一个运行批处理mysql命令(如mysql -e "select..."
)的脚本,我希望总结每个命令的执行时间.
I'm working on a Linux host with mysql command. I have a script that runs batch mysql commands (like mysql -e "select..."
) and I wish to summarize execution time of each of the commands.
有没有办法从命令行获取mysql exec时间?
Is there a way to get mysql exec time from the command line?
例如,在mysql交互模式下,执行结果带有时间,如下所示:
For example, in mysql interactive mode, execution result comes with a time, like this:
mysql> select count(*) from trialtable;
+----------+
| count(*) |
+----------+
| 4000 |
+----------+
1 row in set (0.00 sec)
我可以在命令行中获得相同的配置文件吗?
Can I get the same profile in command line?
谢谢
推荐答案
您可以使用
set profiling=1
,然后,以后
show profiles
这将给出命令和时间的列表.
which will give a list of commands and times.
请参见 http://dev.mysql.com/doc/refman/5.0/zh/show-profiles.html
h/t http://ronaldbradford.com/blog/timing-your -sql-queries-2010-07-07/
这篇关于mysql命令行返回执行时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!