Skip to main content
Glama

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
NameRequiredDescriptionDefault
max_index_size_mbNoMax index size in MB
methodNoMethod to use for analysisdta

Implementation Reference

  • 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)
  • Registration of the `analyze_workload_indexes` tool using `@mcp.tool`.
    @mcp.tool(description="Analyze frequently executed queries in the database and recommend optimal indexes")

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/moecodeshere/mcptrial'

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