Updated
An AI SQL query optimizer for SQL Server should do more than rewrite the text of a query. AI SQL Tuner Studio’s Query Tuner connects to your database with a least-privileged login, reads the query’s execution plan along with the indexes and statistics behind it, and returns a prioritized report: what is slow and why, index scripts with their estimated size, and rewritten queries. It works with SQL Server, Azure SQL Database, Azure SQL Managed Instance and Microsoft Fabric SQL Database, and the Free edition needs no credit card.
What an AI SQL query optimizer does
An AI SQL query optimizer takes a slow query and tells you how to make it faster: which part of the work dominates the cost, which indexes would change the plan, and how to rewrite predicates or joins the optimizer cannot use efficiently. The quality of that advice depends on what the AI can see. A query’s text alone does not show how SQL Server actually executes it, how many rows each step touches, or which indexes and statistics already exist.
Why plan-aware optimization beats text-only optimizers
Most online SQL optimizers work from the query you paste into a web page, and many were built for PostgreSQL and MySQL. They can spot common anti-patterns, but they have no access to your server, so they cannot see your execution plan, your existing indexes, your statistics or your data distribution. Query Tuner is built for SQL Server and reads that evidence directly:
- The execution plan. Query Tuner captures the estimated plan with
SET SHOWPLAN_XML ON, so your query is not executed, and since release 3.3 it also reads the plan’s last actual run, the statistics the plan used and the SET options it was compiled with. - Every operator and warning. Seeks, scans, joins, sorts and spools are evaluated for their cost, along with plan warnings such as missing indexes, TempDB spills, implicit conversions, missing join predicates, columns with no statistics and memory grant problems.
- The tables behind the query. Every referenced table is identified, including tables reached through views, and targeted metadata is collected for each: index usage, sizes, compression and statistics.
The AI then returns a prioritized HTML report with execution-plan analysis, index recommendations with ready-to-run DDL and estimated size, query rewrites with before and after examples, and statistics and parameter-sniffing guidance. For the full list of what Query Tuner collects, see the Query Tuner goal.
Example: a real Query Tuner report
This sample Query Tuner report was generated with GPT-5.6 Luna for a query against the SQLStorm sample database on SQL Server 2022. It rated the query’s estimated cost of 202.053 as critical and traced most of that cost to one non-SARGable join predicate, Posts.Tags LIKE '%' + Tags.TagName + '%', which forces a broad scan of Posts and a nested-loops comparison against all 1,232 tags. Its recommendations include a rewrite of the tag matching, statistics fixes, and targeted indexes such as this filtered, compressed index from the report’s scripts:
CREATE NONCLUSTERED INDEX [IX_Posts_Question_TagScan]ON [dbo].[Posts] ([PostTypeId])INCLUDE ([CreationDate], [Title], [Tags])WHERE [PostTypeId] = 1WITH (DATA_COMPRESSION = PAGE, ONLINE = ON, SORT_IN_TEMPDB = ON);
The report also shows the original and expected plans side by side, the storage each new index adds, and supporting scripts to measure logical reads, CPU and elapsed time before and after you apply a change.
How it works in 3 steps
- Connect read-only. Point AI SQL Tuner Studio at your database with a least-privileged login. No agents, no traces.
- Paste the slow query and run Query Tuner. Choose Low, Medium or High reasoning effort to trade depth for speed.
- Apply the ranked fixes. Review the report, then run the index scripts and rewrites you agree with. Nothing is changed on your server until you run it.
Supported platforms
Every edition, including Free, supports SQL Server 2016 and later (on-premises or in a VM), Azure SQL Database, Azure SQL Managed Instance and Microsoft Fabric SQL Database. Support for Amazon RDS for SQL Server (Standard, Enterprise and Developer editions) is in preview. AI SQL Tuner Studio runs on Windows 10 (version 1809 or later) and Windows 11, on x64 or ARM64, from the Microsoft Store or as a direct download, and on Windows Server as a direct download.
AI SQL Tuner Studio vs. online SQL optimizers
| Capability | AI SQL Tuner Studio (Query Tuner) | EverSQL | SQLAI.ai |
|---|---|---|---|
| Built for | SQL Server, Azure SQL Database, Azure SQL Managed Instance, Fabric SQL Database | PostgreSQL, MySQL and related open-source engines (now part of Aiven) | Many SQL and NoSQL engines, including SQL Server |
| How it runs | Windows desktop app that connects to your database with a least-privileged login | Web-based service | Web-based AI SQL assistant |
| Reads your execution plan, indexes and statistics | Yes | For supported engines | Works mainly from the SQL and schema you provide |
| Index scripts | Yes, with estimated size | Yes, for supported engines | No |
| Query rewrites | Yes, with before and after examples | Yes | Yes |
| Beyond single queries | Six tuning goals, including Index Tuning, Server Health Check and Deadlock Analysis | Ongoing insights for Aiven-hosted databases | SQL generation, formatting and explanation |
| Price | Free edition; paid from $19.99/month | See aiven.io | See sqlai.ai |
For detailed comparisons, see EverSQL alternative for SQL Server and AI SQL Tuner vs. SQLAI.ai.
Editions
Every edition includes Query Tuner and the other five tuning goals. The Free edition includes 10 analyses a month on one server connection with GPT-5.6 Luna, and needs no credit card. Pro, Team and Enterprise add more analyses and connections, High reasoning effort and a bring-your-own AI endpoint, and Team and Enterprise add GPT-6 Sol. Compare editions and pricing.
Frequently asked questions
What is an AI SQL query optimizer?
An AI SQL query optimizer analyzes a slow query and recommends how to make it faster, such as new or changed indexes, query rewrites and statistics fixes. AI SQL Tuner Studio’s Query Tuner does this for SQL Server by giving the AI the query’s execution plan, the indexes and statistics of the tables it uses, and plan warnings, not just the query text.
Does Query Tuner run my query?
No. Query Tuner captures the estimated execution plan with SET SHOWPLAN_XML ON, which compiles the query without executing it. When available, it also reads the plan’s last actual run from SQL Server, along with the statistics the plan used and its SET options.
What permissions does the AI SQL query optimizer need?
Query Tuner works with a least-privileged, read-only login. It needs permissions such as SHOWPLAN and VIEW DATABASE STATE to read plans and metadata. The least-privileged account guide on aisqltuner.com has the full script.
Is there a free AI SQL query optimizer for SQL Server?
Yes. The AI SQL Tuner Studio Free edition includes Query Tuner and every other tuning goal, with 10 analyses a month on one server connection using GPT-5.6 Luna, and needs no credit card.
Does it work with Azure SQL Database and Azure SQL Managed Instance?
Yes. Every edition supports SQL Server 2016 and later, Azure SQL Database, Azure SQL Managed Instance and Microsoft Fabric SQL Database.
Will it change anything on my database?
No. AI SQL Tuner Studio reads metadata and plans and produces a report. Index scripts and query rewrites are applied only if you choose to run them.
Download the Free edition and run Query Tuner on your own slow query, or read the Query Tuner goal documentation first.