All use cases

SQL Optimizer

Improve query speed.

Microservices
Prompt
Analyze this SQL query for performance bottlenecks. Suggest specific indexes to add and rewrite the query using CTEs (Common Table Expressions) for better readability.
Use this

Why this exists

A query that ran fine on a thousand rows can crawl on a million, and the fix is almost never obvious from staring at the SQL. The bottleneck is usually a missing index or a full table scan hiding behind a subquery, but spotting it means reading the query plan, knowing which columns to index, and rewriting the logic without changing the result. Most teams either guess or wait for the one database expert to have a free afternoon. This blueprint builds a tool that does the reading for you.

What the agent does

A SQL query analyzer. You paste in a query and it flags the performance bottlenecks, points to the specific indexes worth adding, and rewrites the query using CTEs, common table expressions, so the logic reads top to bottom instead of nesting subqueries three deep. You get back the concrete index list and a cleaner version of the query that returns the same rows.

You watch it happen in the task workspace: the agent scaffolds the tool, wires the analysis and rewrite logic, and runs a sample query through it to confirm the output before handing you a live preview. The code lands on a branch in your repository with a pull request ready.

Make it yours

The first version handles a single query and you steer it from there with plain follow-up messages:

  • "Target Postgres syntax specifically, including partial indexes."
  • "Estimate the impact of each suggested index before I add it."
  • "Flag N+1 patterns when I paste in a batch of queries."
  • "Show the before-and-after query plan side by side."

Each follow-up wakes the same repository and the agent continues on its own code.

FAQ

Does it connect to my database? Not by default; it analyzes the SQL text you paste. Ask it to connect and it can pull real query plans and table stats.

Which SQL dialect does it assume? It works with standard SQL out of the box; tell it you're on Postgres, MySQL, or another engine and it tailors the index and CTE suggestions.

Will the rewritten query return the same results? Yes, the CTE rewrite restructures for readability, not behavior; the goal is the same rows, faster and easier to read.

SQL Optimizer | OutcomeDev Use Cases