Skip to content
ToolPlankDEV
Database Tools
100% In-Browser Execution

Updated:

Optimize MySQL Query Online with a Free SQL Query Optimizer

Optimize MySQL query online: paste a slow query and get plain-English findings, one-click rewrites, the indexes worth adding and a readable EXPLAIN plan. PostgreSQL and SQL Server work too. Everything runs in your browser, so your queries are never uploaded.

Processing in browser...

Loading the tool. It runs entirely in your browser, so your data is never uploaded.

More free tools you may need next.

Quick Guide

How to use SQL Query Optimizer

Simple step-by-step instructions to get the exact output you need.

  1. 01

    Paste your query and pick your database

    Paste any SELECT, UPDATE or DELETE into the editor, or pick an example. Choose MySQL, PostgreSQL or SQL Server at the top. The analysis updates as you type, so there is no Run button to press.

  2. 02

    Read the findings in plain English

    The Issues tab lists what is slow or risky, sorted by impact. Each finding explains the problem in simple words, with the technical detail one click away. The query health score at the top gives you a quick overall picture.

  3. 03

    Apply the fixes

    Where a rewrite is possible, the finding shows the before and after. Press Apply fix for one, or Fix safe issues for all the safe ones at once. The Optimized SQL panel shows the result, and the Changes view highlights every line that moved. Undo goes back one step.

  4. 04

    Add the suggested indexes

    Open the Index advisor tab for CREATE INDEX statements built from your WHERE, JOIN and ORDER BY columns. Paste your table definitions in the Schema tab and the tool skips indexes you already have.

  5. 05

    Check the real plan with EXPLAIN

    Run EXPLAIN on your own MySQL server and paste the result into the EXPLAIN reader. Each step is explained, full table scans, filesorts and temporary tables are marked, and the slowest step stands out.

How to Optimize a MySQL Query Online

Most slow MySQL queries are slow for a small number of repeated reasons: a function wrapped around an indexed column, a comma join that forgot its condition, a LIKE that starts with a wildcard, a subquery that runs once per row, or a missing index on a join column. This sql query optimizer looks for those patterns in the text of your query and tells you which ones it found.

It reads your SQL with a real parser, not only a text search. That means it knows which tables and aliases the query uses, which conditions are filters and which are joins, and where subqueries start and end. It understands SELECT, UPDATE and DELETE statements, INSERT ... SELECT, WITH clauses, joins, subqueries and UNION. When a statement uses syntax it cannot read, the basic checks still run and the tool says so.

Everything happens in your browser. Your query, your table names and your schema are never uploaded (see the Privacy Policy). You can check this in the Network tab of your browser dev tools.

  1. Paste the query and choose MySQL.
  2. Fix the High impact findings first. These are the patterns that usually decide whether a query takes milliseconds or minutes.
  3. Add the suggested indexes, one at a time, on a copy of your data.
  4. Run EXPLAIN again and keep a change only if the plan got better.

What the Optimizer Checks

The checks come in four groups. Each finding is marked High, Medium or Low impact so you know where to start.

  • Index killers: functions on columns such as DATE(created_at) or LOWER(email), arithmetic on a column, a leading wildcard in LIKE, OR across different columns, a text column compared with a number, and joined columns of different types.
  • Heavy patterns: SELECT * (with the large columns named when you add a schema), ORDER BY RAND(), deep OFFSET pagination, correlated subqueries in the column list, very long IN lists, comma-separated tables and joins with no matching condition.
  • Logic slips: comparing with = NULL, a LEFT JOIN that the WHERE clause turns into an INNER JOIN, HAVING conditions that belong in WHERE, UNION where UNION ALL is enough, UPDATE or DELETE without WHERE.
  • Syntax problems: unclosed quotes, comments and brackets, stray commas, incomplete expressions, empty WHERE clauses and dialect mistakes such as LIMIT in SQL Server or TOP in MySQL.

The health score starts at 100 and drops for each finding, more for errors and high-impact patterns. It is a quick signal about the text of the query. It is not a measurement of speed, because the tool never runs your query or sees your data.

One-Click Rewrites and When They Are Safe

For the patterns below the tool writes the fixed version for you. Each one is labelled Safe or Check first. Safe means the rewritten query returns the same rows. Check first means it usually does what you meant, but depends on your data or your column settings, so read the note before applying it.

  • DATE(col) = '2026-10-15' becomes col >= '2026-10-15' AND col < '2026-10-16', and YEAR(col) = 2026 becomes a date range. The database can then use an index on col. Safe.
  • col = NULL becomes col IS NULL, because = NULL never matches anything. Safe.
  • Comma joins become JOIN ... ON, with the matching conditions moved out of WHERE. Safe when every table is linked to the others by an equality.
  • A LEFT JOIN filtered in WHERE becomes an INNER JOIN, which is what the query already behaves like. Safe.
  • SELECT * becomes the real column names once you add your schema. Safe.
  • IN (subquery) and NOT IN (subquery) become EXISTS and NOT EXISTS. Check first, because NOT IN and NOT EXISTS treat NULL values differently.
  • UNION becomes UNION ALL. Check first, because it keeps duplicate rows.
  • LOWER(col) = 'x' loses the function in MySQL, where the default collations ignore case. Check first, because it only holds for case-insensitive columns.

The Changes view shows a line-by-line comparison of your original query and the optimized one, so you can review exactly what was rewritten before you copy it.

How the Index Advisor Chooses Columns

A composite index works like a phone book sorted by last name, then first name. The database can jump to a last name quickly, but not to a first name alone. So column order matters, and the advisor uses three simple rules.

  • Columns compared with = (or IN) go first, because they narrow the search the most.
  • One range column (>, <, BETWEEN or a prefix LIKE such as 'abc%') goes next. Columns after a range column cannot be used to narrow the search, so only one is added.
  • If there is no range column, the ORDER BY columns follow, which lets the index return rows already sorted and removes the sort step.

For a joined table, its join columns come first, because the database looks up that table once per row from the other side. Without an index there, it scans the whole table again for every row.

Paste your CREATE TABLE statements in the Schema tab and the advisor compares each suggestion with your existing indexes. A suggestion that is already covered is marked as such, and a partly covered one tells you which existing index is close. Without a schema it assumes no indexes exist.

Reading MySQL EXPLAIN Output

EXPLAIN shows how MySQL plans to run a query. The most useful column is type, which says how each table is read. From best to worst, the common values are const and eq_ref (one row through a unique key), ref (matching rows through an index), range (part of an index) and index (the whole index). ALL means every row of the table is read, which gets slower as the table grows.

The Extra column adds the warning signs. Using filesort means the rows are sorted in a separate step. Using temporary means MySQL builds a temporary table, usually for GROUP BY or DISTINCT. Using join buffer means the join column has no usable index. Using index is the opposite of a problem: it means the query is answered from the index alone.

Paste the output into the EXPLAIN reader tab and each step is turned into a plain sentence. It accepts the table output you see in the mysql client, the vertical output from \G, EXPLAIN FORMAT=JSON and EXPLAIN ANALYZE. For EXPLAIN ANALYZE it also shows the time spent in each step and flags the slowest one. Note that EXPLAIN ANALYZE really runs the query, so avoid it on statements that change data.

Building a long IN list from a spreadsheet column? Tidy it first with Sort Lines and Remove Duplicate Lines. For a slow report that runs on a schedule, the Cron Expression Generator helps you pick a quieter time to run it.

Saved Queries, Schema and Report

If you tune the same queries often, press Save query to keep them in this browser and open them again on your next visit. Tick Remember this schema to keep your table definitions too. Both stay on your device only, and only when you choose to save them.

The Copy report button puts a Markdown summary on your clipboard: the original query, the optimized one, the findings and the suggested indexes. It is ready to paste into a pull request, a ticket or a chat message.

What This Tool Cannot Do

It reads your query as text. It does not connect to a database, run your query, measure timings or see your row counts, so it cannot tell you for certain that a query is slow or that a change made it faster. The findings are patterns that often cause trouble, and the right answer always comes from EXPLAIN on data that looks like production.

The parser covers common SQL, but not every vendor extension, stored procedure body or unusual syntax. When it cannot read a statement it falls back to the basic checks and tells you. A result with no findings is a sanity check, not a guarantee that your database will accept the query.

The EXPLAIN reader is written for MySQL output. PostgreSQL and SQL Server plans use a different format and are not read by it, although the query checks, formatter and index advice work for all three databases.

Frequently Asked Questions

Technical Q&A for SQL Query Optimizer

Common questions about edge cases, character encoding, and privacy guarantees.

Paste the query into the editor and choose MySQL. The tool lists patterns that slow queries down, such as functions on columns, SELECT *, comma joins and leading wildcards, and rewrites many of them with one click. Then open the Index advisor for CREATE INDEX statements and paste your EXPLAIN output into the EXPLAIN reader to see how MySQL really runs it.

Yes. It is free, needs no sign-up and has no usage limits beyond the input size. It runs in your browser, so there is nothing to install.

No. The analysis, the index advice and the EXPLAIN reader all run in your browser. Your query, table names and schema are never uploaded, and you can confirm that in your browser's Network tab. A query or schema is stored in your own browser only if you press Save query or tick Remember this schema.

Fixes marked Safe return the same rows, for example turning DATE(col) = a date into a range, or a comma join into JOIN ... ON. Fixes marked Check first, such as NOT IN to NOT EXISTS or UNION to UNION ALL, depend on your data, and the note under each one says what to check. Always compare results on a copy of your data before using a rewrite in production.

It reads the WHERE, JOIN and ORDER BY clauses. Columns compared with equality go first, then one range column, then the ORDER BY columns. For joined tables the join columns come first. With a schema it also skips indexes you already have. It cannot see your data, so treat the order as a good starting point and confirm with EXPLAIN.

Yes. Pick the database at the top. The formatter, syntax checks, parser and index advice work for MySQL, PostgreSQL and SQL Server, and the dialect changes how quotes and identifiers are read and which dialect warnings you see. The EXPLAIN reader only understands MySQL output.

The tool reads the text of the query, so it cannot see problems that come from your data or your server, such as a table with millions of rows, missing statistics, a busy server or a missing index it could not guess. Run EXPLAIN on your own data and paste it into the EXPLAIN reader to see where the time goes.

It is a quick summary of how many known slow or risky patterns the query contains, weighted by impact. 100 means none were found. It is not a measurement of speed, because the tool never runs your query.

No. It catches common mistakes such as unclosed quotes and brackets, stray commas, incomplete expressions, empty conditions and joins with no condition, and it flags statements that start with an unknown word. It does not know every vendor extension, so a clean result does not guarantee that your database will accept the query.

No. Spaces and line breaks never change the speed of a query. Formatting helps you and your team read it, which makes mistakes such as a missing join condition easier to spot. Minify puts the query on one line for use inside application code.