-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat(tools/mysql): add list-table-stats-tool to list table statistics in MySQL and Cloud SQL MySQL source. #2938
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 18 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
98d8842
Added list_table_stats tool for MySQL
sumeetdhingra-google f63fe80
Merge branch 'googleapis:main' into main
sumeetdhingra-google be4c7c3
changes added to verify connected db
sumeetdhingra-google 2f93a19
minor fixes
sumeetdhingra-google 747fbb0
updated tool defination
sumeetdhingra-google 5d5b35d
Merge branch 'googleapis:main' into main
sumeetdhingra-google ea9307d
Merge branch 'googleapis:main' into main
sumeetdhingra-google 9391180
updated validation block and corrected indentation
sumeetdhingra-google 17cd410
Merge branch 'googleapis:main' into main
sumeetdhingra-google 223a00a
Merge branch 'googleapis:main' into main
sumeetdhingra-google 260f2bf
Fixed errors and tool definition
sumeetdhingra-google df6adaf
Merge branch 'googleapis:main' into main
sumeetdhingra-google 578e37b
Applied Suggested changes
sumeetdhingra-google 18c48b7
added RunMySQLListTableStatsTest to cloud-sql-mysql
sumeetdhingra-google 4a62f20
Merge branch 'googleapis:main' into main
sumeetdhingra-google 4503986
added annotations
sumeetdhingra-google 0130402
Merge branch 'main' into main
Yuan325 31ad5b1
Update imports.go
Yuan325 ae3fdde
moved advance usage to about in docs file
sumeetdhingra-google 32d2934
Merge branch 'main' into main
sumeetdhingra-google ffece2c
Merge branch 'main' into main
sumeetdhingra-google 178f364
changes to merge with new repo name mcp-toolbox
sumeetdhingra-google 688ed1a
corrected db name in Cloud SQL MySQL Integration test
sumeetdhingra-google abf0b3e
Merge branch 'main' into main
sumeetdhingra-google 600dd8c
minor changes in format
sumeetdhingra-google 31913b6
Merge branch 'main' into main
sumeetdhingra-google 543ebca
fixed integration test
sumeetdhingra-google 0dd4d0c
fixed indentation
sumeetdhingra-google 4a0939e
Merge branch 'main' into main
Yuan325 b27a38f
Merge branch 'main' into main
Yuan325 429a929
Merge branch 'main' into main
Yuan325 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
docs/en/integrations/mysql/tools/mysql-list-table-stats.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| --- | ||
| title: "mysql-list-table-stats" | ||
| type: docs | ||
| weight: 1 | ||
| description: > | ||
| 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. | ||
| --- | ||
|
|
||
| ## About | ||
|
|
||
| A `mysql-list-table-stats` tool generates table-level performance and resource consumption statistics to facilitate bottleneck identification and workload analysis. | ||
|
|
||
| `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. | ||
|
|
||
| ## Compatible Sources | ||
|
|
||
| {{< compatible-sources others="integrations/cloud-sql-mysql">}} | ||
|
|
||
| ## Requirements | ||
|
|
||
| - `performance_schema` should be turned ON for this tool to work. | ||
|
|
||
| ## Parameters | ||
|
|
||
| This tool takes 4 optional input parameters: | ||
|
|
||
| - `table_schema` (optional): The database where table stats check is to be | ||
| executed. Check all tables visible to the current database if not specified. | ||
| - `table_name` (optional): Name of the table to be checked. Check all tables | ||
| visible to the current user if not specified. | ||
| - `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`) | ||
|
shuzhou-gc marked this conversation as resolved.
|
||
| - `limit` (optional): Max rows to return, default 10. | ||
|
|
||
| ## Example | ||
|
|
||
| ```yaml | ||
| kind: tools | ||
| name: list_table_stats | ||
| type: mysql-list-table-stats | ||
| source: my-mysql-instance | ||
| 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. | ||
| ``` | ||
|
|
||
| ## Output Format | ||
|
|
||
| The response is a json array with the following fields: | ||
| ```json | ||
| [ | ||
| { | ||
| "table_schema": "The schema/database this table belongs to", | ||
| "table_name": "Name of this table", | ||
| "size_MB": "Size of the table data in MB", | ||
| "row_count": "Number of rows in the table", | ||
| "total_latency_secs": "total latency in secs", | ||
| "rows_fetched": "total number of rows fetched", | ||
| "rows_inserted": "total number of rows inserted", | ||
| "rows_updated": "total number of rows updated", | ||
| "rows_deleted": "total number of rows deleted", | ||
| "io_reads": "total number of io read requests", | ||
| "io_read_latency": "io read latency in seconds", | ||
| "io_write_latency": "io write latency in seconds", | ||
| "io_misc_latency": "io misc latency in seconds", | ||
| } | ||
| ] | ||
| ``` | ||
|
|
||
| ## Reference | ||
|
|
||
| | **field** | **type** | **required** | **description** | | ||
| |-------------|:--------:|:------------:|----------------------------------------------------| | ||
| | type | string | true | Must be "mysql-list-table-stats". | | ||
| | source | string | true | Name of the source the SQL should execute on. | | ||
| | description | string | true | Description of the tool that is passed to the LLM. | | ||
|
|
||
|
|
||
| ## Advance Usage | ||
|
sumeetdhingra-google marked this conversation as resolved.
Outdated
|
||
|
|
||
| - **Finding hottest tables**: Identify tables with highest total latency, read or writes based on the `sort_by` column. | ||
| - **Finding tables with most reads**: Identify tables with highest reads by sorting on `rows_fetched`. | ||
| - **Monitoring growth**: Track `row_count` and `size_MB` of table over time to estimate growth." | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.