{{ summaryTitle }}
{{ summaryValue }}

{{ summaryLine }}

{{ badge.label }}{{ badge.value }}
MySQL slow query log analysis controls
Paste an incident slice or load one LOG, SLOW, or TXT file. Raw source stays in this browser and out of the page URL.
{{ sourceMeta }}
{{ sourceActionHint }}
Rank by accumulated cost, tail latency, lock pressure, scan pressure, or recurrence.
Match MySQL long_query_time or the application latency gate used for this review.
sec
Use a tighter gate for OLTP paths and a broader gate for expected analytical scans.
rows
{{ workflowFeedback }}
{{ handoffStatus }}
Leave blank for a neutral report label.
Choose 5–100 rows for each visible ledger.
rows
{{ handoffStatus }}
RankFingerprintSamplesRank metricTotal timeP95Max rowsSignalsStateCopy
{{ row.rank }}{{ row.fingerprint }}{{ row.samples }}{{ formatRankMetric(row.rank_metric) }}{{ formatSeconds(row.total_time_sec) }}{{ formatSeconds(row.p95_time_sec) }}{{ formatInteger(row.max_rows_examined) }}{{ row.signals.join(', ') || 'below gates' }}{{ stateLabel(row.state) }}
{{ handoffStatus }}
EntryTimeQuery timeLock timeRows examinedRows sentCommandFingerprintSignalsCopy
{{ row.entry }}{{ row.time || 'Not logged' }}{{ formatSeconds(row.query_time_sec) }}{{ formatSeconds(row.lock_time_sec) }}{{ formatInteger(row.rows_examined) }}{{ formatInteger(row.rows_sent) }}{{ row.command }}{{ row.fingerprint }}{{ row.signals.join(', ') || 'below gates' }}
{{ handoffStatus }}
PriorityFindingEvidenceNext checkCopy
{{ row.priority }}{{ row.finding }}{{ row.evidence }}{{ row.next_check }}
{{ handoffStatus }}
{{ chartError }}

A slow database incident rarely comes from one spectacular statement. A query that takes 300 ms but runs thousands of times can consume more capacity than a five-second report run once. MySQL slow-query logs make those costs visible by pairing SQL text with elapsed time, lock time, rows sent, rows examined, and optional sorting or temporary-table counters.

Log contents depend on server policy. MySQL normally considers long_query_time, minimum examined rows, administrative-statement settings, no-index logging, and throttling before recording a statement. The entry is written after execution and after locks are released, so file order can differ from start order. Absence from the log does not prove a query was fast.

Four measurements answer different tuning questions:

  • Query_time is the statement's reported execution time in seconds.
  • Lock_time records time spent acquiring locks, not every form of waiting or contention.
  • Rows_examined counts rows examined by the server layer, while Rows_sent counts rows returned to the client.
  • Temporary-table and sort counters point toward extra work but do not identify the correct index by themselves.

Repeated SQL often differs only in literal values. Replacing strings, numbers, UUIDs, and hexadecimal values with placeholders creates a fingerprint that can be grouped across calls. This shows accumulated time, recurrence, tail latency, and scan pressure for a query shape without treating every customer or order ID as a separate statement.

Fingerprints also have limits. Different literals can produce different optimizer plans because data distribution and selectivity change. Two statements with the same simplified shape may use different schemas, indexes, bind types, or execution contexts. Keep representative values and the original incident window available for plan review.

Slow-log analysis prioritizes investigation; it does not prescribe an index. Confirm high-cost fingerprints with current statistics, EXPLAIN or EXPLAIN ANALYZE, transaction context, workload concurrency, and before-and-after measurements.

How to Use This Tool:

Use a MySQL FILE-style excerpt that keeps each # Query_time line with the SQL statement that follows it.

  1. Paste or load the Slow query log from one incident, service, or comparison window. Incomplete blocks without both timing metadata and SQL are excluded.
  2. Choose Review focus. Total time highlights accumulated cost; P95 or max time highlights latency; lock time, rows examined, and sample count highlight different pressure.
  3. Set the Slow threshold from 0 to 86,400 seconds and the Rows examined warning from 0 to one trillion rows. Equality triggers both gates.
  4. Add a Database or service label only when it helps identify the report, and set the visible ledger limit from 5 to 100 rows.
  5. Read Fingerprint hotspots in the selected ranking order, then inspect Query ledger and Tuning findings for the evidence behind each signal.
  6. Take the original SQL and representative literals into a current execution-plan review before changing indexes, schema, or query text.

Interpreting Results:

The first fingerprint changes with Review focus. A query can rank first by total time without having the largest single duration, or rank first by rows examined while contributing little elapsed time. Keep the selected metric visible when sharing a ranked result.

A fail fingerprint has an extreme latency, extreme scan, or disk temporary-table signal. Review means one or more other signals were found. Pass means no local signal matched in the supplied excerpt; it does not certify the query or database.

Parse gaps weaken totals and percentiles because incomplete blocks are excluded. A short sample can also make nearest-rank P95 equal the maximum. Compare the parsed-entry count and time window before treating the ordering as stable.

Technical Details:

FILE slow-log blocks are split around timing and date markers. A usable block needs a finite Query_time and SQL text beginning with a recognized SQL command. Comments, timestamp setup statements, and USE lines are excluded from the SQL text before fingerprinting.

Transformation Core:

Slow query log transformation stages
StageBehavior
ExtractRead timing and row counters from comment fields and join the following SQL into one statement.
FingerprintRemove SQL comments; replace UUIDs, hexadecimal literals, quoted strings, and numbers with ?; reduce placeholder lists in IN (...) to IN (?list); collapse whitespace; keep at most 180 characters.
SignalApply latency, scan, lock, row-yield, temporary-table, sort, and selected SQL-pattern rules to each entry.
GroupCombine entries by SQL command plus fingerprint and calculate sample count, total time, nearest-rank P95, maxima, and total lock time.
RankSort groups by the chosen metric, then total time, then fingerprint text.

Formula Core:

Total time measures accumulated cost. Row yield helps identify scans that return a small fraction of examined rows. P95 uses a nearest-rank rule rather than interpolation.

Ttotal= i=1nQueryTimei P95= xceil(0.95n) rowYield= RowsSentRowsExamined

x is the ascending list of query times, indexed here from 1 for readability. With two samples, nearest-rank P95 selects the larger value. Low row yield is flagged only when at least 1,000 rows were examined and the ratio is below 0.01; a zero examined-row count does not create an infinite ratio.

Rule Core:

MySQL slow query signal and fingerprint state rules
Signal or stateExact condition
Latency gateQuery_time is greater than or equal to the selected slow threshold.
Scan gateRows_examined is greater than or equal to the selected row threshold.
Lock waitLock_time is greater than or equal to 0.1 seconds.
FailMaximum time is at least four times a positive slow threshold, maximum rows examined is at least twenty times a positive row threshold, or a disk temporary table is present.
ReviewAt least one signal exists and no fail rule matches.
PassNo signal exists for the fingerprint in this excerpt.

Input is limited to 2 MiB and the first 10,000 split blocks. Threshold values of zero are valid; they make every non-negative entry meet the basic latency or scan signal, while the four-times and twenty-times extreme rules remain disabled because those require a positive threshold.

Privacy and Limitations:

Slow-log text is processed in the browser and excluded from page URL state. The original SQL can contain customer identifiers, email addresses, tokens, tenant names, comments, or business-sensitive predicates. Fingerprints mask common literals but are not a general-purpose redaction guarantee.

  • Only MySQL FILE-style blocks are parsed; rows copied from the mysql.slow_log table need conversion.
  • The analysis does not know schema statistics, index definitions, server variables, transaction owners, buffer state, or concurrent workload.
  • SQL-pattern signals are text heuristics. For example, SELECT * or a JSON predicate can be acceptable for a specific schema and workload.
  • Changing thresholds changes findings and states, so keep them fixed for before-and-after comparisons.

Worked Examples:

Repeated order lookup

Two statements with different status literals share one fingerprint and take 2.431 and 2.118 seconds. Their total time is 4.549 seconds, nearest-rank P95 is 2.431 seconds, and both meet a 1-second latency gate. If either examines at least twenty times a positive row threshold, the group fails the extreme-scan rule; otherwise its other signals still place it in review.

References: