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

7 skills that great graphic designers need to master

1》Be good at web design 2》Know how to design web p...

Detailed explanation of Svn one-click installation shell script under linxu

#!/bin/bash #Download SVN yum -y install subversi...

MySQL 5.7.21 winx64 installation and configuration method graphic tutorial

This article summarizes the notes for installing ...

Recommended plugins and usage examples for vue unit testing

Table of contents frame First-class error reporti...

How to install the graphical interface in Linux

1. Linux installation (root user operation) 1. In...

Tutorial on using the frameset tag in HTML

Frameset pages are somewhat different from ordina...

CSS3 to achieve floating cloud animation

Operation effect html <head> <meta chars...

Implementing carousel effects with JavaScript

This article shares the specific code for JavaScr...

Detailed explanation of custom swiper component in JavaScript

Table of contents Effect display Component Settin...

js+Html to realize table editable operation

This article shares the specific code of js+Html ...