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

Ubuntu 20.04 turns on hidden recording noise reduction function (recommended)

Recently, when using kazam in Ubuntu 20.04 for re...

CSS3 property line-clamp controls the use of text lines

Description: Limit the number of lines of text di...

Thoughts on truncation of multi-line text with a "show more" button

I just happened to encounter this small requireme...

Summary of Docker Consul container service updates and issues found

Table of contents 1. Container service update and...

How complicated is the priority of CSS styles?

Last night, I was looking at an interview question...

Simple web page code used in NetEase blog

How to use the code in NetEase Blog: First log in...

Introduction to local components in Vue

In Vue, we can define (register) local components...

MySQL tutorial thoroughly understands stored procedures

Table of contents 1. Concepts related to stored p...

Linux kernel device driver system call notes

/**************************** * System call******...

Vue3 manual encapsulation pop-up box component message method

This article shares the specific code of Vue3 man...

The pitfall record of case when judging NULL value in MySQL

Table of contents Preface Mysql case when syntax:...

mysql startup failure problem and scenario analysis

1. One-stop solution 1. Problem analysis and loca...