Configuration·MySQL
MySQL Slow Query Log
Off by default, on in one statement, and the field that matters is not `Query_time` but `Rows_examined` - 400,000 rows read to return 1 is the signature of a missing index.
Performance Guide 33 of 45 Intermediate
- OSUbuntu 26.04 LTS (resolute)
- MySQL8.4.10-0ubuntu0.26.04.1
- Test data400,000 rows, 2 core / 4 GB host
- TimeAbout 14 min
- Reviewed27 August 2026
Written against the versions above. `long_query_time` accepts fractions. The default of 10 seconds is far too high to catch anything on a healthy system - a query taking 10 seconds is already an incident.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| db-a01 | 192.168.0.81 | Ubuntu 26.04 LTS | Primary / Source / Replica Set Member 1 | 2 Core | 4 GB | 50 GB |
Before you start
- The
eventstable, andsudoto read the log file.
-
Check whether it is on
-
Turn it on with a threshold that catches something
-
Run two queries and read what was recorded
-
Turn it off again
Official sources
- MySQL 8.4 Reference Manual - Optimizing Queries with EXPLAIN
- MySQL 8.4 Reference Manual - Obtaining Execution Plan Information
- MySQL 8.4 Reference Manual - Multiple-Column Indexes
- MySQL 8.4 Reference Manual - Skip Scan Range Access
- MySQL 8.4 Reference Manual - The Slow Query Log
- MySQL 8.4 Reference Manual - InnoDB Locking