stats_table
Retrieve table statistics from the Baidu Vector Database to analyze data structure and optimize vector search performance.
Instructions
Get the table statistics in the Mochow instance.
Args:
table_name (str): Name of the table to get statistics.
Returns:
str: A string containing the table statistics.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table_name | Yes |
Implementation Reference
- src/mochow_mcp_server/server.py:545-562 (handler)The handler function for the 'stats_table' MCP tool. It retrieves table statistics via the MochowConnector and formats them into a readable string output.@mcp.tool() async def stats_table(table_name: str, ctx: Context = None) -> str: """ Get the table statistics in the Mochow instance. Args: table_name (str): Name of the table to get statistics. Returns: str: A string containing the table statistics. """ connector = ctx.request_context.lifespan_context.connector stats = await connector.get_table_statistics(table_name) output = f"Table statistics named '{table_name}' in Mochow instance:\n" output += f"TotalRowCount: {str(stats.row_count)}\n" output += f"MemorySizeInByte: {str(stats.memory_size_in_byte)}\n" output += f"DiskSizeInByte: {str(stats.disk_size_in_byte)}\n" return output
- Supporting helper method in MochowConnector class that calls the Mochow API to fetch raw table statistics, used by the stats_table handler.async def get_table_statistics(self, table_name: str) -> HttpResponse: """ Get statistics information about a table. Args: table_name (str): Name of the table. Returns: HttpResponse: The HTTP response containing the table statistics. """ if self.database is None: raise ValueError("Switch to the database before get table statistics") try: return self.database.table(table_name).stats() except Exception as e: raise ValueError(f"Failed to get table statistics: {str(e)}")