How to view the running time of MySQL statements through Query Profiler

How to view the running time of MySQL statements through Query Profiler

The previous article introduced two methods to check the running time of MySQL statements. Today, I will continue to introduce you to check the running time of MySQL statements. Interested friends, let’s learn together!

Query Profiler is a query diagnostic analysis tool that comes with MYSQL. It can be used to analyze the performance bottleneck of a SQL statement. Usually we use explain and slow query log, but they cannot provide accurate analysis.

However, Query Profiler can locate the various resource consumption of a SQL statement, such as CPU, IO, etc., as well as the time consumed by the SQL execution.

Show profiles was added after 5.0.37. To use this feature, make sure the version is after 5.0.37.

1. Log in to MySQL to view the database version:
Login: mysql -u username -p
use databses the database you want to choose: use databses

View the version: show variables like "%version%"; 或者select version();

insert image description here

2. Check whether the profile is enabled. The database is not enabled by default.

View method: show variables like "%pro%";
Setting the start method: set profiling = 1;

insert image description here

You can start executing some SQL statements you want to analyze.

3. After execution, query the SQL execution time: show profiles;
You can view the total execution time of all SQL.

insert image description here

Supplement: show profile cpu, block io, memory, swaps, context switches, source for query 6; you can view the various resource consumption of a SQL statement, such as CPU, IO, etc.

This is the end of this article about how to view the execution time of MySQL statements through Query Profiler. For more information about viewing the execution time of MySQL statements, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • 2 ways to view the running time of MySQL statements
  • Batch kill sqls that run for a long time in mysql

<<:  25 Vue Tips You Must Know

>>:  Html and CSS Basics (Must Read)

Recommend

Use iptables and firewalld tools to manage Linux firewall connection rules

Firewall A firewall is a set of rules. When a pac...

A collection of possible problems when migrating sqlite3 to mysql

Brief description Suitable for readers: Mobile de...

Using iframe techniques to obtain visitor QQ implementation ideas and sample code

Today at work, a friend I added temporarily asked ...

A practical record of checking and processing duplicate MySQL records on site

Table of contents Preface analyze Data Total Repe...

Talking about the practical application of html mailto (email)

As we all know, mailto is a very practical HTML ta...

Summary of common docker commands (recommended)

1. Summary: In general, they can be divided into ...

How does MySQL ensure data integrity?

The importance of data consistency and integrity ...

MySQL 8.0.15 installation and configuration tutorial under Win10

What I have been learning recently involves knowl...

Pure js to achieve the effect of carousel

This article shares the specific code of js to ac...

Example of how to implement value transfer between WeChat mini program pages

Passing values ​​between mini program pages Good ...

About CSS floating and canceling floating

Definition of Float Sets the element out of the n...

JavaScript custom calendar effect

This article shares the specific code of JavaScri...

A brief discussion on the use of GROUP BY and HAVING in SQL statements

Before introducing the GROUP BY and HAVING clause...

Drop-down menu implemented by HTML+CSS3+JS

Achieve results html <div class="containe...