Skip to main content
Glama
aliyun

Hologres MCP Server

Official
by aliyun

get_hg_execution_plan

Analyze SQL query performance in Hologres by retrieving execution plans with runtime statistics to identify optimization opportunities.

Instructions

Get actual execution plan with runtime statistics for a SQL query in Hologres database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe SQL query to analyze in Hologres database

Implementation Reference

  • Registration of the get_hg_execution_plan tool, including its schema definition.
    Tool( name="get_hg_execution_plan", description="Get actual execution plan with runtime statistics for a SQL query in Hologres database", inputSchema={ "type": "object", "properties": { "query": { "type": "string", "description": "The SQL query to analyze in Hologres database" } }, "required": ["query"] } ),
  • Input schema for the get_hg_execution_plan tool.
    inputSchema={ "type": "object", "properties": { "query": { "type": "string", "description": "The SQL query to analyze in Hologres database" } }, "required": ["query"] }
  • Specific handler dispatch in call_tool function that wraps the input query with 'EXPLAIN ANALYZE' for execution plan.
    query = f"EXPLAIN ANALYZE {query}" elif name == "call_hg_procedure": procedure_name = arguments.get("procedure_name") arguments_list = arguments.get("arguments") if not procedure_name:
  • Generic helper function that connects to the database, executes the prepared query (EXPLAIN ANALYZE), fetches results, and formats the execution plan output.
    def handle_call_tool(tool_name, query, serverless = False): """Handle callTool method.""" config = get_db_config() try: with connect_with_retry() as conn: with conn.cursor() as cursor: # 特殊处理 serverless computing 查询 if serverless: cursor.execute("set hg_computing_resource='serverless'") # Execute the query cursor.execute(query) # 特殊处理 ANALYZE 命令 if tool_name == "gather_hg_table_statistics": return f"Successfully {query}" # 处理其他有返回结果的查询 if cursor.description: # SELECT query columns = [desc[0] for desc in cursor.description] rows = cursor.fetchall() result = [",".join(map(str, row)) for row in rows] return "\n".join([",".join(columns)] + result) elif tool_name == "execute_dml_sql": # Non-SELECT query row_count = cursor.rowcount return f"Query executed successfully. {row_count} rows affected." else: return "Query executed successfully" except Exception as e: return f"Error executing query: {str(e)}"

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/aliyun/alibabacloud-hologres-mcp-server'

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