Skip to main content
Glama

Postgres MCP

by crystaldba

explain_query

Analyze SQL query execution plans with detailed cost estimates, simulate hypothetical indexes, and get real execution statistics for optimized database performance on Postgres MCP.

Instructions

Explains the execution plan for a SQL query, showing how the database will execute it and provides detailed cost estimates.

Input Schema

NameRequiredDescriptionDefault
analyzeNoWhen True, actually runs the query to show real execution statistics instead of estimates. Takes longer but provides more accurate information.
hypothetical_indexesNoA list of hypothetical indexes to simulate. Each index must be a dictionary with these keys: - 'table': The table name to add the index to (e.g., 'users') - 'columns': List of column names to include in the index (e.g., ['email'] or ['last_name', 'first_name']) - 'using': Optional index method (default: 'btree', other options include 'hash', 'gist', etc.) Examples: [ {"table": "users", "columns": ["email"], "using": "btree"}, {"table": "orders", "columns": ["user_id", "created_at"]} ] If there is no hypothetical index, you can pass an empty list.
sqlYesSQL query to explain

Input Schema (JSON Schema)

{ "properties": { "analyze": { "default": false, "description": "When True, actually runs the query to show real execution statistics instead of estimates. Takes longer but provides more accurate information.", "title": "Analyze", "type": "boolean" }, "hypothetical_indexes": { "default": [], "description": "A list of hypothetical indexes to simulate. Each index must be a dictionary with these keys:\n - 'table': The table name to add the index to (e.g., 'users')\n - 'columns': List of column names to include in the index (e.g., ['email'] or ['last_name', 'first_name'])\n - 'using': Optional index method (default: 'btree', other options include 'hash', 'gist', etc.)\n\nExamples: [\n {\"table\": \"users\", \"columns\": [\"email\"], \"using\": \"btree\"},\n {\"table\": \"orders\", \"columns\": [\"user_id\", \"created_at\"]}\n]\nIf there is no hypothetical index, you can pass an empty list.", "items": { "additionalProperties": true, "type": "object" }, "title": "Hypothetical Indexes", "type": "array" }, "sql": { "description": "SQL query to explain", "title": "Sql", "type": "string" } }, "required": [ "sql" ], "title": "explain_queryArguments", "type": "object" }
Install Server

Other Tools from Postgres MCP

Related Tools

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/crystaldba/postgres-mcp'

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