analyze_workload_indexes
Analyze frequently executed PostgreSQL queries to recommend optimal indexes for improved database performance and query efficiency.
Instructions
Analyze frequently executed queries in the database and recommend optimal indexes
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| max_index_size_mb | No | Max index size in MB | |
| method | No | Method to use for analysis | dta |
Implementation Reference
- src/postgres_mcp/server.py:407-420 (handler)The implementation of the `analyze_workload_indexes` tool, which delegates to either `DatabaseTuningAdvisor` or `LLMOptimizerTool` via `TextPresentation`.
async def analyze_workload_indexes( max_index_size_mb: int = Field(description="Max index size in MB", default=10000), method: Literal["dta", "llm"] = Field(description="Method to use for analysis", default="dta"), ) -> ResponseType: """Analyze frequently executed queries in the database and recommend optimal indexes.""" try: sql_driver = await get_sql_driver() if method == "dta": index_tuning = DatabaseTuningAdvisor(sql_driver) else: index_tuning = LLMOptimizerTool(sql_driver) dta_tool = TextPresentation(sql_driver, index_tuning) result = await dta_tool.analyze_workload(max_index_size_mb=max_index_size_mb) return format_text_response(result) - src/postgres_mcp/server.py:405-405 (registration)Registration of the `analyze_workload_indexes` tool using `@mcp.tool`.
@mcp.tool(description="Analyze frequently executed queries in the database and recommend optimal indexes")