audit_compaction_debt
Analyze Delta Lake file-size distribution to detect small-file fragmentation debt and generate targeted OPTIMIZE, ZORDER, clustering, and TBLPROPERTIES SQL for faster queries.
Instructions
Evaluate Delta Lake table file-size distribution for small-file fragmentation debt and synthesize targeted OPTIMIZE, ZORDER BY, Liquid Clustering, and TBLPROPERTIES SQL commands.
Usage Guidelines:
Use when troubleshooting slow Delta Lake queries, read amplification, or excessive metadata overhead.
Prerequisites: Obtain file sizes in bytes (e.g. from DESCRIBE DETAIL table_name, Delta transaction logs, or cloud storage inventory).
To forecast pipeline compute cluster DBU burn instead, use forecast_dbu_cost.
Behavior:
Purely analytical calculation; parses file size array and computes fragmentation statistics.
Does NOT connect to cloud object storage or execute the generated OPTIMIZE/ALTER TABLE statements against a live warehouse.
Returns small-file ratios, compaction urgency rating, and copy-pasteable SQL remediation scripts.
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_name": "<table_name>",
"file_sizes_bytes": "<file_sizes_bytes>"
},
"name": "audit_compaction_debt"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table_name | Yes | Three-part Unity Catalog or Delta table name (catalog.schema.table). | |
| file_sizes_bytes | Yes | Array of Parquet data file sizes in bytes from Delta log. | |
| small_file_threshold_mb | No | Threshold in MB below which files count as small (default: 32). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table_name | Yes | Analyzed Delta table identifier. | |
| total_files | Yes | Total number of Parquet files evaluated. | |
| total_size_mb | No | Total table size in megabytes. | |
| recommended_sql | Yes | Targeted SQL remediation command to compact small files. | |
| small_file_count | No | Number of files smaller than the threshold. | |
| small_file_ratio | Yes | Fraction of files that are small (0.0 to 1.0). | |
| compaction_urgency | Yes | Urgency rating for running OPTIMIZE. |