退出mysql mysql> quit Bye [root@localhost ~]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 3 Server version: 5.0.45-log Source distribution
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
查看profiling的值 mysql> select @@profiling; +-------------+ | @@profiling | +-------------+ | 0 | +-------------+ 1 row in set (0.01 sec)
发现已经变为默认值0了,那如果设置系统级会如何呢?
mysql> set global profiling=1; ERROR 1228 (HY000): Variable 'profiling' is a SESSION variable and can't be used with SET GLOBAL mysql>
看到这里报错了。所以mysql sql profile是session级别的。
2. 举个例如,看如何使用
mysql> create table t5 as select * from t1; ERROR 1046 (3D000): No database selected mysql> use backup; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A
mysql> select sum(format(duration,6)) as duration from information_schema.profiling where query_id=7; +----------+ | duration | +----------+ | 0.003688 | +----------+ 1 row in set (0.02 sec)
mysql> select sum(format(duration,6)) as duration from information_schema.profiling where query_id=8; +----------+ | duration | +----------+ | 0.003222 | +----------+ 1 row in set (0.00 sec)