Slow Query Log Analyzer

Find the query shape that ate your database — ranked by total time, not by the loudest single run.

A slow query log is a list of individual slow queries; the problem is almost never an individual query. What hurts a database is a query shape — the same statement with different literals — run hundreds of times, or scanning a million rows to return twenty. This analyzer parses a MySQL/MariaDB slow log or a PostgreSQL duration log, strips the literals into fingerprints, and ranks shapes by total time, with rows examined, p95 and four findings. It is not the generic Log Parser, which splits arbitrary log lines into fields; this tool understands two database slow-log formats and aggregates them. The companion article Slow Query Log Analysis: Rank by Total Time, Not by Loudest Query explains the method. Like the Agent Transcript Auditor, everything runs locally — nothing is uploaded.

Last updated:

1. Paste or drop your slow query log

Drop a slow log file here, or choose one below

Up to 20 MB — parsed in your browser, never uploaded.

🔒 Analysis runs entirely in your browser: pasted text and dropped files are parsed locally and never uploaded, never stored, and never sent anywhere. That matters here more than most tools — slow query logs routinely contain real user data inside their literals.

What a slow query log is — and what fingerprinting does

A slow query log is the database server’s own record of the statements that ran longer than a threshold: MySQL and MariaDB write blocks that start with "# Time:" and a "# Query_time:" header carrying the duration, lock time, rows sent and rows examined, followed by the SQL; PostgreSQL, with log_min_duration_statement set, writes one "duration: N ms statement: …" line per slow statement. Either way the raw log is a flat list of individual runs — useful for spotting one bad moment, misleading for finding what actually costs the database its time.

Fingerprinting is how the list becomes an answer. The analyzer replaces every literal — string, number, hex — with ?, collapses IN (?, ?, ?) lists to IN (?), folds whitespace and lowercases the text, then groups identical results. Six runs of the orders lookup with six different customer ids become one fingerprint with a count of 6 and a total time; that total, not the single loudest run, is what the table ranks by. The rules are deterministic and written down here because a fingerprint is a model of the query, not the query itself.

This is a different job from the Log Parser. The Log Parser is generic: give it almost any log line and it splits the line into fields you can scan. This analyzer is deliberately narrow: it understands the MySQL slow-log block format and PostgreSQL duration lines, reads the timing and row counters those formats carry, and aggregates by fingerprint. If your file is an application log, use the Log Parser; if it is a database slow log, use this.

Two demos are built in, both synthetic. The MySQL demo has 14 entries in 4 fingerprints — a frequent orders lookup, a scan-heavy events query examining 860,000 rows per run, a report join with one 75-second run that alone is 55% of the log’s total time, and a 2-second primary-key lookup. The PostgreSQL demo has 8 entries in 3 fingerprints, including a prepared-statement execution that lands in the same fingerprint as its plain-statement twins. Neither demo contains real data — real slow logs are exactly what should never be pasted into a stranger’s server, which is why this page has no server side at all.

What this analyzer does — and what it does not

It parses your log entirely in your browser (up to 20 MB): MySQL "# Time:" blocks with their Query_time, Lock_time, Rows_sent and Rows_examined headers, "use db;" and "SET timestamp=" plumbing skipped; PostgreSQL "duration:" statement and execute lines with the standard log_line_prefix tolerated and multi-line statements reassembled. Lines it cannot attribute to an entry are counted and shown as unparsed lines — never silently dropped. Per fingerprint it computes count, total, average, max and p95 time (nearest-rank over up to 10,000 stored times per group), total rows examined and sent where the format carries them, and the share of total time. Clicking a fingerprint shows an example full query and the worst single instance. The aggregate exports as CSV (UTF-8 BOM) or JSON.

Four findings are flagged, and there is deliberately no score — this is an analyzer, not a grader. Scan-heavy: a fingerprint whose average rows examined per query exceeds 10,000 is reading far more than it returns. Outlier pain: a fingerprint whose slowest run is over 10× its average hurts unpredictably even when its total is small. Single slow query: one run over 60 seconds. Dominance: one fingerprint over 50% of the log’s total time — fix that one shape first.

It does not connect to your database, run EXPLAIN, or know your schema and indexes — it reads the log you give it, nothing else. It cannot tell you why a query is slow, only where the time and the row scanning concentrate. And it never sends the log anywhere: there is no endpoint for this tool, and the page works offline once loaded.

Be honest about what a slow log can show

The log only contains queries slower than the server’s threshold — long_query_time on MySQL, log_min_duration_statement on PostgreSQL. A query that takes 200 ms but runs ten thousand times an hour never appears here, and it may be your real problem. A slow log answers "of the slow queries, which shapes cost the most" — not "what makes the database slow" in full. Lower the threshold briefly, or pair this with a general query profile, before concluding anything.

Fingerprinting is literal-stripping, and it errs both ways. Two genuinely different queries can share a fingerprint — the same statement against a hot table and an archive table, or identifiers that differ only in case, which the lowercase fold merges — and one logical query can split into several fingerprints when its shape changes (an extra WHERE clause, a different column list). Treat a fingerprint as a strong hint about where to look, then read the example query and the worst instance before changing an index.

Key facts

Slow query logThe server’s record of statements that exceeded a time threshold: MySQL/MariaDB write it with slow_query_log and long_query_time; PostgreSQL with log_min_duration_statement. Queries under the threshold are not in the file at all.
FingerprintA query with its literals replaced by ?, IN lists collapsed and case folded — the shape of the statement. Aggregation by fingerprint is the method of Percona’s pt-query-digest and of this analyzer.
Rows examined vs rows sentMySQL counts how many rows the server inspected (Rows_examined) and how many it returned (Rows_sent). Examined ≫ sent is the classic scan smell: the database read a mountain to hand back a handful.
p95The 95th percentile time: 95% of a fingerprint’s runs were at or under it. Computed here by nearest-rank over the stored run times (up to 10,000 per fingerprint).
log_min_duration_statementThe PostgreSQL setting that logs every statement running at least this many milliseconds, as "duration: N ms statement: …" — the lines this analyzer reads. −1 disables it; 0 logs everything.
long_query_timeThe MySQL/MariaDB threshold, in seconds (fractions allowed), above which a query is written to the slow query log. The default is 10 seconds — far too high to catch most real pain; 1–2 seconds is a common working value.

Frequently asked questions

Is my slow log really never uploaded?

Yes — and for this tool it matters more than most. Slow logs quote the literals from real queries: email addresses in WHERE clauses, names, search terms, sometimes tokens. Paste mode never leaves the text field; file mode reads with the browser FileReader API into page memory. There is no endpoint for this tool at all. The only downloads are the CSV and JSON exports you ask for.

How is this different from the Log Parser tool?

The Log Parser is a general-purpose log tool: it splits arbitrary lines into fields so you can scan them. This analyzer only accepts two formats — MySQL/MariaDB slow-log blocks and PostgreSQL duration lines — but in return it understands what the numbers mean: it fingerprints the SQL, aggregates time and rows per shape, and flags scan-heavy, outlier, single-slow and dominant fingerprints. Different questions, different tools.

One query of mine appears as two fingerprints — or two different queries merged into one. Why?

Both are known limits of literal-stripping. A query whose shape changes — an optional WHERE clause added by the application, a different column list — produces a different fingerprint, correctly by the rules. And the lowercase fold merges identifiers that differ only in case, so the same statement against Orders and orders counts as one shape. The example query and worst instance shown for each fingerprint let you check what actually merged before you act on the totals.