Performance Tuning for mysql SQL statements
Performance Tuning for mysql SQL statements
In server development, there are sometimes requirements on the concurrency, and sometimes an SQL statement, such as a stored procedure, affects the speed. Now, if the execution of an SQL statement is slow during server code execution, how can we optimize it? Performance Tuning for mysql SQL statements
Assume that the following SQL stored procedure is particularly slow for server code execution:
Call sp_wplogin_register (1, 1, 1, '20160301', '20160301 ');
You can perform debugging as follows:
1. Open mysql profiling:
2. then execute the SQL to be optimized. Here we execute two SQL statements, one for commit, and the other for calling the above Stored Procedure statement:
3. Use profiling to display the execution time of each SQL statement. The stored procedure is composed of a series of SQL statements, which are also displayed here:
We can see that the SQL Execution speed at the red mark is far from the same level as other SQL statements. We optimized this line, for example, creating an index for the field f_phone.