The MySQL slow query log is disabled by default. To capture slow statements in a file, make sure slow_query_log is enabled and log_output includes FILE; then set a useful long_query_time threshold. If the log is enabled but empty, check the output destination, threshold, examined-row limit, and statement type before changing application code or indexes.
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
This guide shows the runtime and startup configuration, explains where the log is written, diagnoses the common “enabled but empty” and “file not found” failures, and turns recurring entries into targeted SQL or schema changes.
As an Amazon Associate I earn from qualifying purchases.
What the MySQL slow query log records
The slow query log is a diagnostic stream for statements that take longer than the configured execution-time threshold and satisfy the examined-row requirement. The MySQL Reference Manual states: “The slow query log consists of SQL statements that take more than long_query_time seconds to execute and require at least min_examined_row_limit rows to be examined.”
long_query_time is the main filter. Its documented default is 10 seconds, which is often too high for finding application requests that feel slow even though they finish in one or two seconds. min_examined_row_limit adds a second condition: a statement must examine at least that many rows before it is written. A query that exceeds the time threshold but examines fewer rows can therefore be omitted.
#1 Best Overall
- [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
- [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
- [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
- [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
- [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.
The log entry includes timing and result-size information such as Query_time, Lock_time, Rows_sent, and Rows_examined. Those values help separate CPU or I/O work from lock waits and show whether a statement scans far more rows than it returns.
Check the current configuration first
Run this as a user allowed to read global system variables. It gives you the complete state needed to explain most logging problems:
SHOW GLOBAL VARIABLES WHERE Variable_name IN (
'slow_query_log','slow_query_log_file','log_output','long_query_time',
'min_examined_row_limit','log_queries_not_using_indexes',
'log_slow_admin_statements','log_throttle_queries_not_using_indexes'
);
Record the output before making changes. In particular, note whether log_output is FILE, TABLE, both, or NONE; the actual path in slow_query_log_file; and whether the threshold or row limit is higher than expected.
Enable the log at runtime
Runtime changes take effect without restarting the server, but they are normally not persistent across a restart. Use a short, controlled diagnostic period first, then put the desired values into the deployment’s startup configuration.
1. Select a destination
For a file, select FILE:
SET GLOBAL log_output = 'FILE';
If you also need the table destination, specify both destinations explicitly:
SET GLOBAL log_output = 'FILE,TABLE';
TABLE writes entries to mysql.slow_log. NONE suppresses query output even when slow_query_log is enabled, so it is a common reason for an apparently working but empty log.
2. Turn on slow logging and choose a threshold
SET GLOBAL slow_query_log = ON;
SET GLOBAL long_query_time = 1;
This example captures statements taking more than one second. Choose a threshold that produces a manageable diagnostic sample for your workload. Moving the threshold toward zero can create a very large stream, especially on a busy server. The global value is used by new sessions; reconnect or start a new client session when testing a changed session-sensitive value.
3. Adjust the examined-row filter when needed
If you need to capture statements that examine only a small number of rows, inspect min_examined_row_limit and lower it appropriately. The setting is part of the logging decision, so a high value can hide a statement even when its elapsed time exceeds long_query_time. Make this change deliberately: a lower row limit can increase volume.
Rank #2
- 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
- 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
- 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
- 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
- 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
4. Broaden capture for special cases
Normal slow-log behavior does not include every kind of statement. By default, administrative statements and statements that do not use indexes are excluded. Enable the relevant switches only for the investigation that requires them:
SET GLOBAL log_slow_admin_statements = ON;
SET GLOBAL log_queries_not_using_indexes = ON;
Capturing every no-index query can produce bursts on workloads that legitimately scan small tables. Limit that stream with:
SET GLOBAL log_throttle_queries_not_using_indexes = 10;
The throttle value limits the rate of no-index entries; choose a bound that gives you evidence without allowing the diagnostic log to dominate disk or I/O.
5. Choose a file name, where the deployment permits it
You can set the global slow_query_log_file variable where the server and hosting environment allow it:
SET GLOBAL slow_query_log_file = '/var/log/mysql/my-slow.log';
When the file name changes, the server closes the already open file and opens the new one. Use an absolute path when you want a specific directory. A relative path is resolved in the server’s data directory, with a default host-based file name when no explicit name is supplied.
Make the setting persistent at startup
For a self-managed server, add the equivalent options to the MySQL option file used by that installation or pass them as launch arguments:
[mysqld]
slow_query_log=ON
slow_query_log_file=/var/log/mysql/my-slow.log
log_output=FILE
long_query_time=1
The option-file location and persistence method vary by operating system, package, container image, and managed service. Confirm which configuration source your service actually reads, validate the file path and permissions, and restart through the deployment’s normal service mechanism. A setting entered only with SET GLOBAL can disappear at the next restart.
Managed MySQL platforms may expose these variables through a parameter group or server configuration panel instead of a local option file. Apply the provider’s documented process and verify the resulting values with SHOW GLOBAL VARIABLES; do not assume that editing a file inside a container or client host changes the database server.
Rank #3
- [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
- [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
- [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
- [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
- [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
Where to find the slow query log
File output
Read the exact path from the server, not from a remembered default:
SELECT @@global.slow_query_log_file;
Then inspect that path on the database server’s filesystem. An absolute value points to the stated directory. A relative value normally resolves under the MySQL data directory. Check that the directory exists, that the account running the server can write there, and that the filesystem has free space. A client machine’s filesystem is irrelevant unless it is also the database host.
Table output
When log_output includes TABLE, query the table from SQL:
SELECT *
FROM mysql.slow_log
ORDER BY start_time DESC
LIMIT 20;
The table destination is useful when you cannot read the server’s filesystem directly. Confirm that your account has permission to read mysql.slow_log and that the server is actually writing to TABLE, not only to FILE or NONE.
Why the log is enabled but empty
Work through these checks in order; each one can independently prevent an entry from appearing.
Output is going somewhere else
log_output='NONE'suppresses query entries.log_output='TABLE'sends entries tomysql.slow_log, not to a file.- A file is written only when
FILEis included inlog_output. - If both destinations are required, use
FILE,TABLErather than replacing one with the other.
The test did not cross the filters
Compare the test statement’s execution time with long_query_time and its examined-row count with min_examined_row_limit. A statement that completes below either condition is correctly omitted. Remember that a changed global value may not alter the session that was already connected; reconnect before testing.
The statement is administrative or uses no index
Administrative statements and no-index statements are excluded by default. Turn on log_slow_admin_statements for the former and log_queries_not_using_indexes for the latter. Use the no-index throttle if enabling that option creates excessive output.
You are watching the wrong server
In a pool, container stack, failover pair, or managed service, the client may connect to a different instance than the one whose filesystem or variables you inspected. Run the variable query through the same connection path used by the application and identify the server before checking its log file.
Rank #4
- Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
- Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
- All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
- Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
- Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
The file cannot be opened
If slow_query_log is on and FILE is selected but no file appears, inspect the value of @@global.slow_query_log_file, then verify the directory, ownership, permissions, and available space on the server host. An invalid or unwritable path prevents useful file output even though the variable remains enabled.
Control log growth during an investigation
A one-second threshold may be appropriate for a short investigation but too noisy for permanent operation. Lowering long_query_time toward zero records many ordinary statements. Enabling log_queries_not_using_indexes can be even more verbose because a workload may contain frequent scans that are harmless on small tables.
- Define a bounded observation window and note the current settings.
- Enable only the capture switches needed for the question you are answering.
- Use
log_throttle_queries_not_using_indexeswhen investigating no-index statements. - Restore a useful threshold and disable broad capture options after collecting representative samples.
- Verify that the resulting file or table volume is acceptable before leaving the settings in place.
The primary documentation does not establish a universal percentage of performance overhead. Treat logging cost as workload- and configuration-dependent, and judge it from the server’s own resource behavior during the bounded interval.
Replicas and missing replicated statements
Replicas do not log replicated queries by default. On MySQL 8.0.26 and later, the setting for this behavior is log_slow_replica_statements. Earlier releases use log_slow_slave_statements. Check the server version before applying either name.
Row-based replication limits the effect of these settings because the replica applies row events rather than replaying the original SQL statement in the same way as statement-based replication. If an expected statement is absent, first establish whether it originated locally or arrived through replication, identify the replication format, and then check the version-appropriate variable.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Read and prioritize entries
A slow-log line gives you more than a single elapsed-time number:
Query_time: total statement execution time.Lock_time: time attributed to lock waits.Rows_sent: rows returned to the client.Rows_examined: rows inspected while producing the result.
Compare frequency, total time, and the relationship between rows examined and rows sent. A statement repeated thousands of times can matter more than a rare outlier. A large examined-to-sent gap often points to an inefficient access path, but it is a prioritization clue rather than proof: confirm the cause with an execution plan and account for parameter values, data distribution, and concurrency.
Summarize recurring statements with mysqldumpslow
The MySQL distribution includes mysqldumpslow for grouping and summarizing a long file. This command sorts by query time and prints the 20 highest entries:
Best Value
mysqldumpslow -s t -t 20 /path/to/host-slow.log
Use the summary to find recurring statement patterns rather than opening thousands of raw lines one by one. Then select representative instances, including different parameter values where possible.
Validate with a query plan
Run EXPLAIN for each representative statement. Where the deployed MySQL version supports an execution-analysis facility, use it to compare the optimizer’s estimates with observed work. Check access type, chosen indexes, examined rows, join order, and whether a filter is applied only after a large scan. Do not infer a fix from the slow-log text alone.
How to fix the statements you find
Add or refine an index when the plan scans too much
If the plan shows a broad scan for a selective predicate, evaluate an index whose leading columns match the filtering and join conditions. Composite-column order matters: an index that begins with an unselective column may not reduce the scan. Re-run the representative query and compare rows examined, execution time, and plan choice against realistic data.
An index is not free. It consumes storage, adds write and maintenance work, and can introduce a less stable plan when parameter values vary. Test inserts, updates, and representative read patterns before making the change permanent.
Rewrite SQL when the predicate prevents efficient access
Use the plan to identify expressions, unnecessary columns, avoidable joins, or result sets that force extra work. Rewrite only when the revised statement preserves the required semantics. Measure the revised form with the same data and concurrency conditions; a query that is faster for one parameter can be worse for another.
Investigate lock time separately
A high Lock_time relative to Query_time points toward contention rather than a missing index alone. Examine transaction scope and concurrent activity before changing access paths. An index may reduce scanning while leaving a blocking transaction untouched.
Include schema and workload trade-offs in the decision
Compare remediation options on the dimensions that affect production behavior:
| Decision axis | Questions to answer |
|---|---|
| Latency reduction | Does the change lower execution time for the recurring statement, not just for one sample? |
| Rows examined and I/O | Does it reduce the amount of data scanned and read? |
| Write and storage cost | What extra space and insert/update work does a new index require? |
| Plan stability | Does the plan remain appropriate across parameter values and data distributions? |
| Operational risk | What is the rollout, locking, compatibility, and rollback impact of changing SQL, schema, or server settings? |
After deploying a change, watch the same statement pattern in the slow log again. Improvement means more than one fast execution: the recurring frequency, timing, and rows-examined profile should move in the intended direction under normal workload.
Quick Recap
A repeatable diagnostic workflow
- Establish the target. Connect to the exact server handling the slow requests and save the current global variables.
- Select the destination. Choose
FILE,TABLE, or both, and verify that the chosen destination is readable and writable. - Set a bounded threshold. Choose
long_query_timefor the observation window; inspectmin_examined_row_limitas well. - Broaden selectively. Enable administrative or no-index capture only when that evidence is needed, and throttle no-index logging if necessary.
- Collect representative entries. Include recurring statements and varied parameter values rather than relying on one outlier.
- Summarize. Use
mysqldumpslowto group the file and rank candidates by time. - Validate. Run
EXPLAINand supported execution analysis, then compare rows examined, rows sent, lock time, and plan behavior. - Change one cause at a time. Test an index, SQL rewrite, or transaction adjustment against realistic data and concurrency.
- Recheck and normalize. Confirm that recurring latency improves, then restore thresholds and switches that were enabled only for diagnosis.
- Persist deliberately. Put the final settings in the deployment’s actual startup configuration if the log should survive a restart.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




