optimize_table
Rebuild MySQL or MariaDB tables to reclaim free space and reduce fragmentation. Preview with dry_run=True; prior size and fragmentation stats are recorded for audit.
Instructions
[WRITE][risk=medium] OPTIMIZE TABLE (rebuild, reclaim data_free). Records prior stats.
No undo (a rebuild has no inverse); the prior size/fragmentation stats are captured for the audit trail. InnoDB maps this to ALTER TABLE ... FORCE (online DDL, brief locks) — schedule off-peak for hot tables. Pass dry_run=True to preview.
Args: table: Table name (optionally schema-qualified, e.g. shop.orders). dry_run: If True, preview without running. target: Target name from config; omit for the default.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"table": "<table>"
},
"name": "optimize_table"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table | Yes | ||
| target | No | ||
| dry_run | No |