MySQL SQL statement performance tuning simple example

MySQL SQL statement performance tuning simple example

MySQL SQL statement performance tuning simple example

When doing server development, sometimes there are certain requirements for concurrency, and sometimes it is a certain SQL statement, such as a stored procedure, that affects the speed. Now suppose that during the execution of the server code, a certain SQL statement executes slowly. How can we optimize it?

Suppose now the server code executes the following SQL stored procedure very slowly:

call sp_wplogin_register(1, 1, 1, '830000', '222222');

You can debug as follows:

1. Open mysql profiling:


2. Then execute the SQL that needs to be tuned. Here we execute two SQL statements, one commit statement and the other one is to call the above stored procedure statement:


3. Use profiling to display the execution time of each SQL statement. The stored procedure consists of a series of SQL statements, which are also broken down and displayed here:


It can be seen that the execution speed of the sql marked in red is far from the same level as other sql statements. We optimize this row, for example, by creating an index for the field f_phone.

Thank you for reading, I hope it can help you, thank you for your support of this site!

You may also be interested in:
  • How to install and configure MySQL and change the root password
  • 10 ways to optimize MySQL performance
  • Two important parameters in Mysql optimization and tuning: table_cache and key_buffer
  • MySQL slow query search and tuning test
  • How to check and tune mysql performance
  • Analyze MySQL replication and tuning principles and methods

<<:  Creating a file system for ARM development board under Linux

>>:  Steps to transplant the new kernel to the Linux system

Recommend

How to modify the default storage engine in MySQL

mysql storage engine: The MySQL server adopts a m...

Three ways to copy MySQL tables (summary)

Copy table structure and its data The following s...

Implementation of automatic completion of Docker commands

Preface I don't know how long this friend has...

CSS3 radar scan map sample code

Use CSS3 to achieve cool radar scanning pictures:...

How to install JDK and Mysql on Ubuntu 18.04 Linux system

Platform deployment 1. Install JDK step1. Downloa...

Several common methods of sending requests using axios in React

Table of contents Install and introduce axios dep...

The images in HTML are directly replaced by base64 encoded strings

Recently, I came across a webpage that had images ...

Solutions to invalid is Null segment judgment and IFNULL() failure in MySql

MySql Null field judgment and IFNULL failure proc...

How to backup MySQL regularly and upload it to Qiniu

In most application scenarios, we need to back up...

100-1% of the content on the website is navigation

Website, (100-1)% of the content is navigation 1....

How to optimize a website to increase access speed update

Recently, the company has begun to evaluate all s...

mysql security management details

Table of contents 1. Introduce according to the o...

How to configure Jupyter notebook in Docker container

Jupyter notebook is configured under the docker c...

Vue echarts realizes horizontal bar chart

This article shares the specific code of vue echa...