Query Optimizer
Optimize slow SQL queries for faster database performance
gpt-4o-mini
Your prompt will appear here…
Your beautifully formatted article will appear here once you generate.
No history yet
Your generations will appear here. Sign in to save them permanently.
Which query is making the dashboard take nine seconds? You have the slow query log open, one statement is clearly the problem, and it runs to a hundred lines of joins somebody wrote two years ago. The Query Optimizer takes that statement and hands back a rewritten version with the reasoning beside it.
Query Optimizer replaces the afternoon of staring at a hundred line join, trying to work out which part went slow. Paste the statement and a rewritten version comes back, with the reason for each change and the indexes worth adding.
What is Query Optimizer?
The Query Optimizer is an AI tool for tuning SQL you already have. You paste a statement, it comes back rewritten and explained. How much you get depends on how much context you paste in.
| What you paste in | What comes back |
|---|---|
| A slow SELECT with its joins | A rewritten version, plus the reason behind each change |
| The query and your table definitions | Index ideas matching the columns you filter and sort on |
| The query and an EXPLAIN plan you ran | That plan read back to you in plain English |
Why Slow Queries Are Hard To Spot By Eye
Nothing in a slow query looks wrong. It was fine when the table held ten thousand rows. These are the patterns that turn up.
- A function wrapped around a column quietly stops an index being used
- A subquery inside the WHERE clause runs again for every row
- SELECT * drags back columns the report never displays
- ORDER BY on an unindexed column sorts the whole result in memory
- The join order was harmless until one table passed a million rows
How Does Query Optimizer Work?
Paste the statement into the prompt box, and paste your table definitions under it if you have them. In the advanced options, set Database to the engine you actually run, because index syntax differs between them. Set Output Type to Query, Complexity to Optimized and Format to Explained, which returns a rewrite with reasoning rather than a bare statement.
Include Indexes is already on and matters most here. Add Constraints and Include Sample Data belong to building a schema from scratch, so leave them alone. Pick a model from the selector, generate, then copy the result into your editor.
One Slow Orders Report, Rewritten
Say the nightly orders report joins orders, customers and order items, filters on a date range and sorts by total. It ran in under a second last year and takes nine now. You paste the statement with the three table definitions and set Database to MySQL.
What comes back is the same report written differently. The correlated subquery becomes a join, the date filter moves onto the raw column instead of sitting inside a function, and SELECT * becomes the six columns the report actually shows. Under it sits the reasoning and an index suggestion covering the order date with the customer id.
Measure It Before You Replace Anything
What the rewrite gives you
- A second opinion on a query you have stared at too long
- The reason behind each change, so the pattern sticks
- Index ideas you can try on a copy first
What it cannot know
- It never connects to your database and never runs anything
- Row counts, data spread and server settings are invisible to it
- A rewrite can return different rows when the original join was subtle
Important Run EXPLAIN on both versions against a copy of real data, and compare the rows they return. The Query Optimizer reads text, not your server, so the only timing that counts is the one you measure.
No sign up sits between you and a rewrite. Every EizTools tool is free and carries its own settings panel rather than one shared box of options, so pick a model from the selector and generate. If the query does not exist yet and you are starting from a sentence about what you want counted, the SQL Generator writes it from plain English first.
Frequently Asked Questions
Does Query Optimizer connect to my database?
No. Nothing is connected, scanned or executed. You paste the query as text and the answer is written from that, which is why an EXPLAIN plan on your own server is still the deciding test.
Why does the engine setting matter for a rewrite?
Because index behaviour differs more than people expect. The same statement tuned for MySQL and for PostgreSQL comes back differently, so set Database to the engine you actually run before you generate.
Should I paste the table definitions as well?
Yes, whenever you can. Column types, primary keys and existing indexes decide half the advice. Without them the suggestions stay generic, because there is no other way for the tool to see your schema.
What is the difference between Complexity and the Detail Level slider?
Complexity changes how far the rewrite goes, from Simple through to Optimized. The slider changes how much explanation arrives with it. Optimized with the slider near its starting 60 percent suits most work.
A slow query never announces which line is the problem, and staring at it longer rarely helps. A rewrite with reasons attached gives you something to test instead of something to guess at. Paste your statement above, read the reasoning, then measure both versions yourself.