SHOW PROFILES Syntax(MySql)
2011-04-24 13:25
211 查看
12.4.5.29. SHOW PROFILES
Syntax
This section does not apply to MySQL Enterprise Server users.SHOW PROFILE [[code]type[,
type] ... ]
[FOR QUERY
n]
[LIMIT
row_count[OFFSET
offset]]
type:
ALL
| BLOCK IO
| CONTEXT SWITCHES
| CPU
| IPC
| MEMORY
| PAGE FAULTS
| SOURCE
| SWAPS
[/code]
The
SHOW PROFILESand
SHOW PROFILEstatements display profiling information that indicates resource usage for statements executed during the course of the current session.
Profiling is controlled by the
profilingsession variable, which has a default value of 0 (
OFF). Profiling is enabled by setting
profilingto 1 or
ON:
mysql> [code]SET profiling = 1;
[/code]
SHOW PROFILESdisplays a list of the most recent statements sent to the master. The size of the list is controlled by the
profiling_history_sizesession variable, which has a default value of 15. The maximum value is 100. Setting the value to 0 has the practical effect of disabling profiling.
All statements are profiled except
SHOW PROFILESand
SHOW PROFILE, so you will find neither of those statements in the profile list. Malformed statements are profiled. For example,
SHOW PROFILINGis an illegal statement, and a syntax error occurs if you try to execute it, but it will show up in the profiling list.
SHOW PROFILEdisplays detailed information about a single statement. Without the
FOR QUERYdisplays information for statementnclause, the output pertains to the most recently executed statement. If [code]FOR QUERYnis included, [code]SHOW PROFILE
n. The values of
ncorrespond to the
Query_IDvalues displayed by
SHOW PROFILES.
The
LIMITrows. Ifrow_countclause may be given to limit the output to [code]row_count
LIMITis given,
OFFSETrows into the full set of rows.offsetmay be added to begin the output [code]offset
By default,
SHOW PROFILEdisplays
Statusand
Durationcolumns. The
Statusvalues are like the
Statevalues displayed by
SHOW PROCESSLIST, althought there might be some minor differences in interpretion for the two statements for some status values (see Section 7.10, “Examining Thread Information”).
Optional
typevalues may be specified to display specific additional types of information:
ALLdisplays all information
BLOCK IOdisplays counts for block input and output operations
CONTEXT SWITCHESdisplays counts for voluntary and involuntary context switches
CPUdisplays user and system CPU usage times
IPCdisplays counts for messages sent and received
MEMORYis not currently implemented
PAGE FAULTSdisplays counts for major and minor page faults
SOURCEdisplays the names of functions from the source code, together with the name and line number of the file in which the function occurs
SWAPSdisplays swap counts
Profiling is enabled per session. When a session ends, its profiling information is lost.
mysql> [code]SELECT @@profiling;
+-------------+
| @@profiling |
+-------------+
| 0 |
+-------------+
1 row in set (0.00 sec)
mysql>
SET profiling = 1;
Query OK, 0 rows affected (0.00 sec)
mysql>
DROP TABLE IF EXISTS t1;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>
CREATE TABLE T1 (id INT);
Query OK, 0 rows affected (0.01 sec)
mysql>
SHOW PROFILES;
+----------+----------+--------------------------+
| Query_ID | Duration | Query |
+----------+----------+--------------------------+
| 0 | 0.000088 | SET PROFILING = 1 |
| 1 | 0.000136 | DROP TABLE IF EXISTS t1 |
| 2 | 0.011947 | CREATE TABLE t1 (id INT) |
+----------+----------+--------------------------+
3 rows in set (0.00 sec)
mysql>
SHOW PROFILE;
+----------------------+----------+
| Status | Duration |
+----------------------+----------+
| checking permissions | 0.000040 |
| creating table | 0.000056 |
| After create | 0.011363 |
| query end | 0.000375 |
| freeing items | 0.000089 |
| logging slow query | 0.000019 |
| cleaning up | 0.000005 |
+----------------------+----------+
7 rows in set (0.00 sec)
mysql>
SHOW PROFILE FOR QUERY 1;
+--------------------+----------+
| Status | Duration |
+--------------------+----------+
| query end | 0.000107 |
| freeing items | 0.000008 |
| logging slow query | 0.000015 |
| cleaning up | 0.000006 |
+--------------------+----------+
4 rows in set (0.00 sec)
mysql>
SHOW PROFILE CPU FOR QUERY 2;
+----------------------+----------+----------+------------+
| Status | Duration | CPU_user | CPU_system |
+----------------------+----------+----------+------------+
| checking permissions | 0.000040 | 0.000038 | 0.000002 |
| creating table | 0.000056 | 0.000028 | 0.000028 |
| After create | 0.011363 | 0.000217 | 0.001571 |
| query end | 0.000375 | 0.000013 | 0.000028 |
| freeing items | 0.000089 | 0.000010 | 0.000014 |
| logging slow query | 0.000019 | 0.000009 | 0.000010 |
| cleaning up | 0.000005 | 0.000003 | 0.000002 |
+----------------------+----------+----------+------------+
7 rows in set (0.00 sec)
[/code]
Note
Profiling is only partially functional on some architectures. For values that depend on the
getrusage()system call,
NULLis returned on systems such as Windows that do not support the call. In addition, profiling is per process and not per thread. This means that activity on threads within the server other than your own may affect the timing information that you see.
SHOW PROFILESand
SHOW PROFILEwere added in MySQL 5.0.37.
You can also get profiling information from the
PROFILINGtable in
INFORMATION_SCHEMA. See Section 18.17, “The
INFORMATION_SCHEMA PROFILINGTable”. For example, the following queries produce the same result:
SHOW PROFILE FOR QUERY 2; SELECT STATE, FORMAT(DURATION, 6) AS DURATION FROM INFORMATION_SCHEMA.PROFILING WHERE QUERY_ID = 2 ORDER BY SEQ;
相关文章推荐
- mysql中的show profiles在5.6.14版本被丢弃
- MySQL查找SQL耗时瓶颈 SHOW profiles
- mysql show profiles 查看sql语句性能
- mysql show profiles使用分析sql性能
- mysql show profiles 使用分析sql 性能
- MySQL性能分析语句 show profile/show profiles
- mysql 分析3使用分析sql 性能 show profiles ;
- Mysql内置优化工具show profiles
- MySQL Error :SHOW PROFILES
- mysql show profiles 使用分析sql 性能
- mysql show profiles使用分析sql性能
- MySQL查找SQL耗时瓶颈SHOW profiles
- MySQL查找SQL耗时瓶颈 SHOW profiles
- mysql 分析3使用分析sql 性能 show profiles ;
- MYSQL性能分析之show profiles
- MySQL性能分析语句 show profile/show profiles
- mysql show profiles 使用分析sql 性能
- MySQL SHOW Syntax
- show profiles 查看MySQL语句的执行时间
- MySQL性能分析语句 show profile/show profiles