Working with SQL query optimizers powered by LLMs has its ups and downs. I’ve noticed that even with tools like ChatGPT or Claude, the process can feel awkward:
Write a prompt → Paste the query → Wait → Refine prompt → Repeat
This cycle is fine once or twice, but quickly becomes tedious — especially for long or complex queries.
So I built a tool that removes prompt engineering from the equation and focuses purely on helping you analyze and optimize SQL queries.
How It Works
1. Paste your SQL query
2. Select your database (PostgreSQL, MySQL, SQL Server, etc.)
3. Click “Analyze”
You’ll Get
- ✅ A list of suggestions with brief reasoning
- 🔄 A rewritten (optimized) version of your query
- 🎯 A confidence tag for each recommendation (High / Medium / Low)
Want deeper insights?
You can optionally add:
- EXPLAIN plans
- Schema
- Indexes
- Table stats
The tool will use this additional context to refine its suggestions and increase recommendation confidence.
Deeper Technical Rationale
The tool supports two levels of analysis:
1. Standard Analysis (available to all users)
When you paste a SQL query and click “Analyze”, the system runs a one-step evaluation:
- Parses the query syntax and structure.
- Identifies common inefficiencies.
- Generates a list of suggestions based on known performance patterns and best practices.
- Provides an optimized version of the query.
- Assigns confidence tags based on available context.
This mode is fast and lightweight, ideal for quick feedback.
2. Deep Analysis (available to registered users)
Deep Analysis follows a multi-stage reasoning process using an internal AI agent:
Hypothesis Generation
The model builds multiple performance-related hypotheses based on the SQL query and any provided context — including schema, EXPLAIN plans, table/index stats, constraints, etc.Validation and Filtering
It then self-evaluates each recommendation. Weak or irrelevant suggestions are filtered out. This step prevents common LLM hallucinations or overly generic advice.Optimized Query Generation
A refined, rewritten query is generated — informed by the validated insights and context.
This approach improves both precision and reliability of recommendations, especially for complex queries involving joins, CTEs, subqueries, or large tables.
Who is this for?
This tool isn’t trying to replace profilers or DB-specific advisors. It’s designed for:
- Developers who want quick feedback on queries
- Teams who want to share and discuss queries
- People learning SQL who want to understand improvements
Give It a Shot
You can try the tool here: https://sqli.to
I’d love to hear your thoughts❤️
Top comments (0)