SQL Optimiser
Analyse a SQL query for performance. Returns a rewritten query, index suggestions and what each change improves.
Pay by wallet (x402) AI-generated
sql-optimize Example
Example answer
{
"dialect": "postgres",
"explanation": "The provided SQL query 'test' is not a valid SQL statement. Please provide a valid SELECT, INSERT, UPDATE, or DELETE query for optimization analysis.",
"changes_made": [],
"original_sql": "test",
"optimized_sql": "Unable to optimize - invalid input provided",
"estimated_improvement": "N/A",
"index_recommendations": []
} Inputs
| Field | Type | Required | What it is |
|---|---|---|---|
sql | string | Yes | — |
dialect | string | No | — |
table_schema | string | No | — |
Output fields
How reliably each field appears in a successful answer.
| Field | Type | Appears |
|---|---|---|
improvements | array | Always (present in every successful answer) |
optimized_sql | string | Always (present in every successful answer) |
estimated_improvement | string | Always (present in every successful answer) |
index_recommendations | array | Always (present in every successful answer) |
How to call it
The same tool through each route. MCP clients reach it through Strale’s server at https://api.strale.io/mcp; the call below is what the agent sends.
# Needs an API key. max_price_cents caps what this call may cost.
curl -X POST https://api.strale.io/v1/do \
-H "Authorization: Bearer $STRALE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"capability_slug": "sql-optimize",
"inputs": {
"sql": "SELECT * FROM users WHERE active = true LIMIT 10",
"dialect": "postgres",
"table_schema": "users(id INT, name TEXT, email TEXT, active BOOL, created_at TIMESTAMP)"
},
"max_price_cents": 5
}' {
"tool": "strale_execute",
"arguments": {
"slug": "sql-optimize",
"inputs": {
"sql": "SELECT * FROM users WHERE active = true LIMIT 10",
"dialect": "postgres",
"table_schema": "users(id INT, name TEXT, email TEXT, active BOOL, created_at TIMESTAMP)"
},
"max_price_cents": 5
}
} import { Strale } from "straleio";
const strale = new Strale({ apiKey: process.env.STRALE_API_KEY! });
const result = await strale.do({
capability_slug: "sql-optimize",
inputs: {
"sql": "SELECT * FROM users WHERE active = true LIMIT 10",
"dialect": "postgres",
"table_schema": "users(id INT, name TEXT, email TEXT, active BOOL, created_at TIMESTAMP)"
},
max_price_cents: 5,
}); import os
from straleio import Strale, DoRequest
strale = Strale(api_key=os.environ["STRALE_API_KEY"])
result = strale.do(DoRequest(
capability_slug="sql-optimize",
inputs={
"sql": "SELECT * FROM users WHERE active = true LIMIT 10",
"dialect": "postgres",
"table_schema": "users(id INT, name TEXT, email TEXT, active BOOL, created_at TIMESTAMP)",
},
max_price_cents=5,
)) # No account. The first request answers 402 with the price in USDC;
# an x402 client pays it from your wallet and repeats the request.
curl -i 'https://api.strale.io/x402/v2/sql-optimize?sql=SELECT+*+FROM+users+WHERE+active+%3D+true+LIMIT+10&dialect=postgres&table_schema=users%28id+INT%2C+name+TEXT%2C+email+TEXT%2C+active+BOOL%2C+created_at+TIMESTAMP%29' Limitations
Performance gains depend on your database
Optimisation suggestions are generic — actual performance gains depend on your database engine, data size, and index configuration
What to do instead: Benchmark the suggested queries with EXPLAIN ANALYZE against your own data.
Related tools
- Agent Trace Analysis €0.20
- API Docs Generator €0.20
- API Mock Responses €0.05
- Changelog Generator €0.03
- Code Converter €0.05
- Commit Message Generator €0.05