Databases 2 min read

Master MySQL Query Profiler: Identify CPU & I/O Bottlenecks Efficiently

This guide explains how to enable MySQL’s Query Profiler, retrieve summary and detailed profiling data, and analyze CPU and I/O usage to pinpoint performance bottlenecks in your queries, including commands to list profiles, view specific query details, and interpret the results for optimization.

Java High-Performance Architecture
Java High-Performance Architecture
Java High-Performance Architecture
Master MySQL Query Profiler: Identify CPU & I/O Bottlenecks Efficiently

To optimize a query you must first identify whether its performance bottleneck stems from excessive CPU computation or heavy I/O operations. MySQL’s Query Profiler provides this insight.

Usage

(1) Enable the profiler by executing the command: SET profiling = 1; (2) After enabling, MySQL automatically records profiling information for every executed query. Run several queries as a test.

(3) Retrieve a summary of the stored profiles with: SHOW PROFILES; (Image showing the output of SHOW PROFILES)

SHOW PROFILES output
SHOW PROFILES output

(4) To obtain detailed profiling for a specific query, use its Query_ID from the summary: SHOW PROFILE CPU, BLOCK IO FOR QUERY 5; (Image showing detailed CPU and I/O information for the query)

Detailed profile output
Detailed profile output
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

performance tuningI/OmysqlDatabase OptimizationCPUQuery Profiler
Java High-Performance Architecture
Written by

Java High-Performance Architecture

Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.