About this tool
Flag non-sargable predicates and costly plan nodes, then build a prompt that explains the query plan in plain language.
A SQL explain prompt builder scans a query for predicates that stop an index being used — a function wrapped around a filtered column, a LIKE with a leading wildcard, NOT IN, ORDER BY with no row limit — and scans any pasted EXPLAIN output for the plan nodes your engine prints when it falls back to scanning or sorting on disk. It then writes a prompt that asks for the plan read node by node, the single most expensive step, and fixes ordered by effort against expected gain. Supports PostgreSQL, MySQL and MariaDB, SQLite, SQL Server and Oracle, each with its own plan command and node vocabulary.
Open SQL Explain Prompt Builder on AltFTool — it loads instantly in your browser.
Paste your code or data sample into the workspace.
Pick the format, conversion, or analysis you need.
Copy the polished result straight back into your project.
The patterns that most often defeat an index are found in the SQL itself, before anyone reads the plan.
Seq Scan, type: ALL, Using filesort, TABLE ACCESS FULL — the prompt uses the names your engine actually prints.
Every suggested index has to name its exact columns and order, and every fix has to declare its write-side or behaviour cost.
It means the engine is reading every row of the table rather than seeking through an index. That is the right choice when the query returns a large fraction of the table, and the wrong one when it returns a handful of rows — in which case the usual causes are a missing index, a non-sargable predicate, or statistics that are out of date.
Sargable is short for Search ARGument ABLE: a predicate the engine can satisfy with an index seek. Wrapping the column in a function, as in WHERE LOWER(email) = ?, or starting a LIKE with a wildcard, as in LIKE '%gmail.com', makes the predicate non-sargable and forces a scan. Comparing the bare column, or adding an expression index, restores the seek.
PostgreSQL: EXPLAIN (ANALYZE, BUFFERS). MySQL 8 and MariaDB: EXPLAIN ANALYZE, or EXPLAIN FORMAT=JSON. SQLite: EXPLAIN QUERY PLAN. SQL Server: capture the actual execution plan, with SET STATISTICS IO, TIME ON for the counts. Oracle: EXPLAIN PLAN FOR, then select from DBMS_XPLAN.DISPLAY.
The planner works from table statistics. When estimated and actual row counts differ by an order of magnitude, the statistics are usually stale, the column values are skewed, or a correlation between two columns is invisible to the planner. Refreshing statistics is the first thing to try, before adding an index.