MySQL Analysis-profile Detailed introduction
- Profiling is open from the mysql5.0.3 version.
After the profile is started, all queries including the wrong statements are logged.
This tool can be used to query the SQL execution state, how much time is spent on System lock and table lock, etc.
It is important to locate the I/O consumption and CPU consumption of a statement. (The largest two-part resource consumed by SQL statement execution is IO and CPU)
- After mysql5.7, profile information will gradually be discarded, MySQL recommended to use the performance schema
Use
- View profile status: Show variables like "%pro%";
- Open/close Profile:set profiling = 1/0
Start analysis: Show profiles;
- We can also query for a single, finer execution: Show profile for query 4; The number behind is query_id.
Clear the SQL cache: Reset query cache, so that our analysis results more accurate, to obtain an objective data results.
MySQL--->profile use