Skip to main content
Glama

query_optimizer

Analyze slow SQL queries with execution plans, table statistics, and index recommendations to identify and resolve performance issues.

Instructions

Optimize slow queries - EXPLAIN plan, table stats, index recommendations.

LEVEL: Query (single query optimization)

USE FOR: slow query diagnosis, CREATE INDEX suggestions, execution plans. DO NOT USE FOR: running queries (execute_query), syntax validation (analyze_query).

Examples: query_optimizer(query='SELECT * FROM orders WHERE customer_id=123', schema='shipment') query_optimizer(query='SELECT * FROM users', schema='public', run_explain=True)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSQL query to optimize
run_explainNoRun EXPLAIN ANALYZE (executes in rollback)
timeout_msNoTimeout in ms (5 min default)
schemaNoSchema for table stats lookup. REQUIRED. Use get_schema() to list available schemas.
urlNoDatabase URL

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must fully disclose behavior. It mentions that running EXPLAIN ANALYZE 'executes in rollback' and includes timeout, but does not explicitly state whether the tool is read-only or if it can create indexes (as implied by 'CREATE INDEX suggestions'). More explicit safety information would improve transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear headings, bullet points, and examples. Key information is front-loaded, and every sentence adds value. No extraneous text.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the presence of an output schema (context signals indicate it exists) and the tool's moderate complexity, the description covers purpose, usage, parameters, and examples. It is sufficient for an agent to select and invoke the tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Parameter schema coverage is 100%, so baseline is 3. The description adds value by explaining that 'schema' is REQUIRED (though not marked in schema) and suggests using get_schema() to list available schemas, and clarifies that 'run_explain' executes in a rollback. This goes beyond the schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Optimize slow queries - EXPLAIN plan, table stats, index recommendations.' It specifies the level (Query) and distinguishes from siblings by listing what not to use it for (execute_query, analyze_query). Examples further clarify its usage.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit usage guidelines: 'USE FOR: slow query diagnosis, CREATE INDEX suggestions, execution plans' and 'DO NOT USE FOR: running queries (execute_query), syntax validation (analyze_query).' This provides clear context on when to use versus alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/snss10/DBeast'

If you have feedback or need assistance with the MCP directory API, please join our Discord server