analyze_table
Collect statistics information from Amazon Redshift tables to optimize query performance and database efficiency.
Instructions
Analyze table to collect statistics information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| schema | Yes | Schema name | |
| table | Yes | Table name |
Implementation Reference
- Validates the 'schema' and 'table' parameters and constructs the ANALYZE SQL statement for the analyze_table tool.elif name == "analyze_table": schema = args.get("schema") table = args.get("table") if not all([schema, table]): raise ValueError("'schema' and 'table' parameters are required when calling analyze_table tool") sql = f"ANALYZE {schema}.{table}"
- Executes the constructed SQL using the database connection and returns a success message specific to the analyze_table tool.with conn.cursor() as cursor: cursor.execute(sql) if name == "analyze_table": return [TextContent(type="text", text=f"Successfully analyzed table {schema}.{table}")]
- Defines the input schema, description, and registration of the analyze_table tool in the list_tools function.Tool( name="analyze_table", description="Analyze table to collect statistics information", inputSchema={ "type": "object", "properties": { "schema": { "type": "string", "description": "Schema name" }, "table": { "type": "string", "description": "Table name" } }, "required": ["schema", "table"] } ),