gather_hg_table_statistics
Execute the ANALYZE TABLE command on Hologres databases to collect table statistics, improving query optimization performance for better query plans.
Instructions
Execute the ANALYZE TABLE command to have Hologres collect table statistics, enabling QO to generate better query plans
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| schema | Yes | Schema name in Hologres database | |
| table | Yes | Table name in Hologres database |
Implementation Reference
- src/hologres_mcp_server/server.py:404-421 (registration)Registers the 'gather_hg_table_statistics' tool, including its description and input schema requiring 'schema' and 'table' parameters.Tool( name="gather_hg_table_statistics", description="Execute the ANALYZE TABLE command to have Hologres collect table statistics, enabling QO to generate better query plans", inputSchema={ "type": "object", "properties": { "schema": { "type": "string", "description": "Schema name in Hologres database" }, "table": { "type": "string", "description": "Table name in Hologres database" } }, "required": ["schema", "table"] } ),
- Defines the input schema for the tool, specifying schema and table as required string parameters.inputSchema={ "type": "object", "properties": { "schema": { "type": "string", "description": "Schema name in Hologres database" }, "table": { "type": "string", "description": "Table name in Hologres database" } }, "required": ["schema", "table"] }
- Handler logic in call_tool function: validates inputs, constructs the ANALYZE query, and passes to execution helper.elif name == "gather_hg_table_statistics": schema = arguments.get("schema") table = arguments.get("table") if not all([schema, table]): raise ValueError("Schema and table are required") query = f"ANALYZE {schema}.{table}" elif name == "get_hg_query_plan":
- In handle_call_tool helper: executes the ANALYZE query via psycopg and returns a success message tailored for this tool.cursor.execute(query) # 特殊处理 ANALYZE 命令 if tool_name == "gather_hg_table_statistics": return f"Successfully {query}"