Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Find a slow MySQL query by measuring a repeatable slow case, identifying the statement responsible, inspecting its proposed execution plan with EXPLAIN, and then checking actual work with EXPLAIN ANALYZE when your deployed version supports it. Use the slow query log for historical evidence, Performance Schema for server-level waits and stages, and plan changes only after the measurements point to a specific cause.

This sequence avoids guessing. It also separates an inefficient SQL plan from delays caused by locks, disk I/O, CPU pressure, or concurrency elsewhere on the server.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What MySQL query profiling actually measures

Query profiling is the process of collecting evidence about where database time is spent. It is not one command or one report. Different MySQL tools answer different questions:

  • Which statements have been slow? The slow query log records statements that exceed the configured long_query_time and examined-row threshold.
  • What plan does the optimizer expect to use? EXPLAIN describes the proposed execution plan without running the statement.
  • What work did one execution really perform? EXPLAIN ANALYZE executes the statement and reports measurements for its iterators.
  • Is the SQL plan the problem at all? Performance Schema can expose statement, wait, and stage activity, helping you distinguish query work from locks, I/O, CPU, or contention.

Start with a repeatable use case in which performance is considered too slow. The MySQL Performance Schema guidance treats that repeatability as the first step: without the same request, parameters, and workload conditions, a before-and-after comparison is unreliable.

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application: attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.

Choose the right profiling method

Method Evidence Scope Production considerations
Slow query log Historical statements that exceed long_query_time and the examined-row threshold Many statements over time Low-friction capture; mysqldumpslow can summarize a large log
Performance Schema Instrumented statement, wait, and stage measurements Server and application activity Enable the needed instrumentation for a repeatable slow case; use measurements instead of guesses
EXPLAIN Estimated access paths, rows, join order, indexes, partitions, and extra operations One statement and its proposed plan Predictive and normally safe because it does not execute the target statement
EXPLAIN ANALYZE Estimated cost and rows compared with time to first row, iterator time, rows returned, and loops One executed statement Available from MySQL 8.0.18; it runs the statement, so use a controlled environment for writes

These tools complement one another. A slow-log entry tells you what deserves attention, EXPLAIN shows what the optimizer intends, and EXPLAIN ANALYZE tests whether that intention matches reality. Performance Schema fills in the gaps when the plan looks reasonable but users still wait.

Capture a repeatable slow case

Define the symptom before changing SQL

Record the exact statement shape, parameter values or ranges, approximate result size, and the workload condition under which it is slow. A query that is fast for a selective customer ID can be slow for a value that matches a large fraction of the table. Capture enough context to replay the same case after every change.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Keep the SQL text and its bound values, while removing secrets from any shared diagnostic record.
  • Note whether the delay is first-row latency, total completion time, or a timeout.
  • Record concurrent activity, transaction state, and whether the data is representative of production.
  • Use the same application path or client when possible; a hand-run query may not reproduce connection settings, prepared statements, or transaction behavior.

Use the slow query log for historical evidence

The slow query log is the quickest way to find statements that repeatedly cross your latency policy. MySQL writes a statement when it exceeds long_query_time and the configured examined-row threshold. This makes it useful when the problem is intermittent or affects many different requests.

Enable logging through your normal MySQL configuration and change the threshold to match the workload you are investigating. A threshold that is too high hides important statements; one that is too low can create excessive log volume. Treat the setting as an operational trade-off rather than a universal performance target.

After collecting enough activity, use the bundled mysqldumpslow utility to aggregate similar statements. Its summaries help you rank recurring query shapes instead of reading thousands of individual log lines. Preserve the original log when you need to inspect parameter values, timestamps, or execution details that a summary omits.

Use Performance Schema for server-level measurements

Performance Schema is appropriate when you need to understand what the server and application are waiting on. Begin with the repeatable slow use case, then enable the statement, stage, or wait instrumentation needed to observe it. The collected data can show time spent in SQL execution, storage-engine operations, metadata or row locks, file I/O, and other stages.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth

Do not turn on every instrument indiscriminately on a busy server. Select the consumers and instruments that answer the current question, monitor the added overhead, and remove temporary diagnostics when the investigation ends. Keep enough history to compare a slow execution with a normal one.

Inspect the optimizer’s proposal with EXPLAIN

Run EXPLAIN on the exact statement

MySQL describes EXPLAIN as providing information about how it executes statements. Run it against the same SQL text and representative parameters that produced the slow case:

EXPLAIN SELECT ...;

For a machine-readable representation, request JSON output:

EXPLAIN FORMAT=JSON SELECT ...;

JSON is useful when a plan contains nested joins, cost details, or fields that are difficult to scan in the traditional tabular output. Save the plan before and after a change so you can see which access path actually changed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read the plan from access path to result

  • Access type: Identify whether a table is reached through a selective lookup, a range, an index walk, or a full table scan. A scan is not automatically wrong, but it deserves scrutiny on a large table.
  • Possible and chosen indexes: Compare the candidate indexes with the index MySQL selected. A missing candidate can indicate that the predicate or join condition is not indexable; a rejected candidate may have poor selectivity.
  • Estimated rows and filtering: The estimated row count is central to join-order decisions. A large estimate means later operators may process much more data than the application ultimately needs.
  • Join order and predicates: Check which table is read first and whether each join has a usable condition. A weak or missing join predicate can multiply intermediate rows.
  • Partitions: Confirm that only relevant partitions are considered when partitioning is part of the design.
  • Extra operations: Look for sorting, temporary structures, or other work that explains latency. Treat these fields as clues to verify, not as an automatic command to rewrite the query.

Read the whole plan rather than focusing on a single row. A table scan on a tiny table may be cheaper than an index lookup, while a scan feeding a large join can dominate total work.

Measure actual work with EXPLAIN ANALYZE

What it adds

EXPLAIN ANALYZE was introduced in MySQL 8.0.18. It executes the statement and reports both estimates and measurements, including estimated cost, estimated rows, time to first row, iterator execution time, rows returned, and loop counts. The comparison is often more informative than either estimate or elapsed time alone.

Rank #3
Sale
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black | LED mouse pad with 14 lighting modes, covers keyboard & mouse, anti-slip rubber base, waterproof surface, USB powered
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
EXPLAIN ANALYZE SELECT ...;

Use the syntax supported by the exact MySQL release deployed in your environment. Documented releases also support EXPLAIN ANALYZE for multi-table UPDATE and DELETE, and for TABLE statements; verify support and syntax before relying on those forms.

Protect data when measuring writes

Because the statement runs, do not casually execute an updating or deleting statement with EXPLAIN ANALYZE against production data. Prefer a safe copy of the data. If a controlled transaction strategy is appropriate for the statement, confirm exactly what is rolled back, what locks are taken, and what side effects occur before testing. A read query can still consume CPU, memory, I/O, and connection capacity, so schedule measurements responsibly.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Compare estimates with observations

Use the output to locate the iterator where reality diverges from the plan. If the optimizer estimates a small input but the iterator processes many rows, downstream joins and sorts may be expensive even when their own estimates look modest. If time to first row is low but total iterator time is high, the query may be returning or sorting a large result. If one loop is cheap but repeated thousands of times, the aggregate cost can dominate.

Turn plan evidence into a diagnosis

Estimated rows are far below actual rows

This pattern points to a cardinality problem. Statistics may be stale, the data may be highly skewed, predicates may be correlated, or the available index may not describe the filter well. Refresh statistics with ANALYZE TABLE, then rerun EXPLAIN and EXPLAIN ANALYZE. If the estimate remains wrong, investigate a more selective or better-ordered index and the interaction between correlated predicates.

A large table is scanned

First verify that a scan is truly harmful under the real workload. Then check whether the query has a predicate on the intended column, whether data types match across comparisons, and whether functions or expressions prevent an index from being used efficiently. Review composite-index column order and make sure the join condition is present. Forcing an index can conceal a statistics or data-distribution problem and may become worse as the table changes, so treat hints as a last resort supported by measurements.

One iterator consumes most of the time

Focus on that iterator and its input rather than rewriting the entire statement. Determine whether it is reading too many rows, performing an avoidable sort, repeatedly probing a poorly indexed table, or waiting on a resource. A targeted index or predicate change is easier to validate and less likely to damage another workload.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.

The join order produces exploding intermediate rows

Inspect every join predicate and the estimated and actual rows entering each join. Missing, nonselective, or non-sargable conditions can multiply rows before the final filter. Improve the index available to the join columns, correct the predicate, or reduce the input earlier when the result semantics permit it.

The plan appears reasonable but the request remains slow

Use Performance Schema wait and stage data. The delay may be caused by row or metadata locks, storage latency, CPU saturation, memory pressure, or concurrency rather than an inefficient access path. Compare a slow execution with a normal execution under similar load. Rewriting SQL will not remove a lock wait or a saturated storage device.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Apply the smallest evidence-based fix

Check indexes on filters and joins

Index columns used to locate rows and connect tables, but design indexes around the actual predicates and their selectivity. For a composite index, verify that the leading columns support the common filter or join pattern. An index that exists but is rarely selective may be correctly rejected by the optimizer.

Keep predicates searchable

Review functions, implicit conversions, expressions, and mismatched data types on filtered or joined columns. These can prevent efficient index access or force MySQL to evaluate many rows before it can apply the condition. Rewrite only when the result semantics remain identical, and confirm the change with a new plan and measurement.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Refresh statistics when estimates are stale

Run ANALYZE TABLE when the data distribution has changed or the estimated rows are consistently inaccurate. Statistics maintenance is not a substitute for an appropriate index, but it can correct a plan chosen from obsolete information. Recheck both the estimate and the actual execution after statistics are refreshed.

Reduce unnecessary work

Return only the columns and rows the application needs, avoid avoidable full-result sorts, and push selective conditions as close to the data source as the query semantics allow. These changes should be driven by the expensive iterator identified in the measurements, not by a generic rule that every query must be rewritten.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.

A repeatable production workflow

  1. Describe the slow case. Capture the exact SQL shape, representative parameters, expected result size, latency symptom, and workload context.
  2. Find recurring statements. Review the slow query log for statements exceeding long_query_time and the examined-row threshold. Aggregate repeated forms with mysqldumpslow.
  3. Instrument the case. Use Performance Schema to observe statement, stage, and wait activity needed to explain the delay.
  4. Save a baseline plan. Run EXPLAIN, and use JSON output when nested plan details need machine-readable inspection.
  5. Measure a safe execution. Run EXPLAIN ANALYZE for a read statement, or use a controlled non-production strategy for a write. Record estimates, actual rows, iterator times, first-row time, and loops.
  6. Classify the bottleneck. Decide whether evidence points to cardinality, access path, join explosion, an expensive iterator, or an external wait.
  7. Make one focused change. Adjust an index, predicate, statistics, or workload condition that directly addresses the diagnosed cause.
  8. Repeat the same measurement. Compare the identical workload and plan before changing anything else.
  9. Check collateral effects. Confirm that other important statements, write rates, lock behavior, and resource consumption did not regress.
  10. Remove temporary instrumentation. Keep the slow-log and Performance Schema settings that are part of your operating policy, but disable diagnostic collection that is no longer needed.

Validation, benchmarking, and common mistakes

Validate the same workload, not a convenient one

MySQL performance varies with data volume, cache state, concurrent sessions, hardware, configuration, and the distribution of parameter values. A small benchmark result is not a universal improvement percentage. Re-run the same slow case, then test representative values and concurrency before declaring the change successful.

Do not confuse estimated cost with elapsed time

Optimizer cost is a planning signal, not a promise of wall-clock latency. Use EXPLAIN ANALYZE and Performance Schema to see actual iterator work and waits. A lower estimated cost is useful only when the measured execution also improves.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not run write statements casually with EXPLAIN ANALYZE

The command executes the target statement. An update or delete can change data, hold locks, and affect other sessions. Test on a safe copy or use a transaction procedure whose behavior has been verified for that statement.

Do not force a plan before checking statistics

An unexpected index choice can result from stale or skewed statistics. Refresh statistics and inspect actual row counts before adding a hint. A forced plan that helps one parameter value can harm another as data and workload change.

Do not treat optimizer trace as a stable API

Optimizer trace can provide detail complementary to EXPLAIN, but MySQL documents that its format and content are subject to change between versions. Use it as a diagnostic aid tied to the deployed release, not as a parser contract for long-lived tooling.

Version and operational safety notes

  • EXPLAIN ANALYZE begins with MySQL 8.0.18. Check the exact release documentation for supported statement types and syntax before deploying a diagnostic command.
  • Performance Schema instrumentation should be selected for the question you are answering; broader collection can add overhead and produce more data than you can interpret.
  • The slow query log is valuable for historical discovery, but it is not a complete explanation of every delay. Lock waits and resource contention may require Performance Schema evidence.
  • Keep credentials, personal data, and application secrets out of shared query captures and diagnostic exports.
  • Use a controlled rollout for any index or SQL change, because improvements are workload-specific and can shift optimizer choices for other statements.

Effective MySQL profiling is a measurement loop: capture a reproducible slow statement, inspect the predicted plan, measure actual iterators when safe, fix the narrow cause indicated by the evidence, and validate under the same workload. That discipline replaces speculation with an auditable explanation of where the time went.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.