|
| 1 | +--- |
| 2 | +title: "mysql-list-table-stats" |
| 3 | +type: docs |
| 4 | +weight: 1 |
| 5 | +description: > |
| 6 | + A "mysql-list-table-stats" tool report table statistics including table size, total latency, rows read, rows written, read and write latency for entire instance, a specified database, or a specified table. |
| 7 | +--- |
| 8 | + |
| 9 | +## About |
| 10 | + |
| 11 | +A `mysql-list-table-stats` tool generates table-level performance and resource consumption statistics to facilitate bottleneck identification and workload analysis. |
| 12 | + |
| 13 | +`mysql-list-table-stats` outputs detailed table-level resource consumption including estimated row counts, table size, a complete breakdown of CRUD activity (rows fetched, inserted, updated, and deleted), and IO statistics such as total, read, write and miscellaneous latency. The output is a JSON formatted array of the top 10 MySQL tables ranked by total latency. |
| 14 | + |
| 15 | +Below are some use cases for `mysql-list-table-stats` |
| 16 | +- **Finding hottest tables**: Identify tables with highest total latency, read or writes based on the `sort_by` column. |
| 17 | +- **Finding tables with most reads**: Identify tables with highest reads by sorting on `rows_fetched`. |
| 18 | +- **Monitoring growth**: Track `row_count` and `size_MB` of table over time to estimate growth." |
| 19 | + |
| 20 | +## Compatible Sources |
| 21 | + |
| 22 | +{{< compatible-sources others="integrations/cloud-sql-mysql">}} |
| 23 | + |
| 24 | +## Requirements |
| 25 | + |
| 26 | +- `performance_schema` should be turned ON for this tool to work. |
| 27 | + |
| 28 | +## Parameters |
| 29 | + |
| 30 | +This tool takes 4 optional input parameters: |
| 31 | + |
| 32 | +- `table_schema` (optional): The database where table stats check is to be |
| 33 | + executed. Check all tables visible to the current database if not specified. |
| 34 | +- `table_name` (optional): Name of the table to be checked. Check all tables |
| 35 | + visible to the current user if not specified. |
| 36 | +- `sort_by` (optional): The column to sort by. Valid values are `row_count`, `rows_fetched`, `rows_inserted`, `rows_updated`, `rows_deleted`, `total_latency_secs` (defaults to `total_latency_secs`) |
| 37 | +- `limit` (optional): Max rows to return, default 10. |
| 38 | + |
| 39 | +## Example |
| 40 | + |
| 41 | +```yaml |
| 42 | +kind: tools |
| 43 | +name: list_table_stats |
| 44 | +type: mysql-list-table-stats |
| 45 | +source: my-mysql-instance |
| 46 | +description: Display table statistics including table size, total latency, rows read, rows written, read and write latency for entire instance, a specified database, or a specified table. Specifying a database name or table name filters the output to that specific db or table. Results are limited to 10 by default. |
| 47 | +``` |
| 48 | +
|
| 49 | +## Output Format |
| 50 | + |
| 51 | +The response is a json array with the following fields: |
| 52 | +```json |
| 53 | +[ |
| 54 | + { |
| 55 | + "table_schema": "The schema/database this table belongs to", |
| 56 | + "table_name": "Name of this table", |
| 57 | + "size_MB": "Size of the table data in MB", |
| 58 | + "row_count": "Number of rows in the table", |
| 59 | + "total_latency_secs": "total latency in secs", |
| 60 | + "rows_fetched": "total number of rows fetched", |
| 61 | + "rows_inserted": "total number of rows inserted", |
| 62 | + "rows_updated": "total number of rows updated", |
| 63 | + "rows_deleted": "total number of rows deleted", |
| 64 | + "io_reads": "total number of io read requests", |
| 65 | + "io_read_latency": "io read latency in seconds", |
| 66 | + "io_write_latency": "io write latency in seconds", |
| 67 | + "io_misc_latency": "io misc latency in seconds", |
| 68 | + } |
| 69 | +] |
| 70 | +``` |
| 71 | + |
| 72 | +## Reference |
| 73 | + |
| 74 | +| **field** | **type** | **required** | **description** | |
| 75 | +|-------------|:--------:|:------------:|----------------------------------------------------| |
| 76 | +| type | string | true | Must be "mysql-list-table-stats". | |
| 77 | +| source | string | true | Name of the source the SQL should execute on. | |
| 78 | +| description | string | true | Description of the tool that is passed to the LLM. | |
| 79 | + |
| 80 | + |
0 commit comments