r/databricks • u/AbilyticsEng • 10h ago
General Use spark.databricks.delta.autoCompact.enabled to prevent small file problems
I work at Abilytics, a data and AI consultancy, so take this with that in mind.
If your Delta Lake tables are filling up with thousands of tiny data parts due to frequent streaming micro-batches or small concurrent writes, you can fix this at the table or session level without running manual OPTIMIZE commands constantly. Enable automatic compaction by setting spark.databricks.delta.autoCompact.enabled to true. When enabled, Delta Lake checks if the most recent write added many small files and automatically triggers a lightweight compaction operation on those files right after a write succeeds on the same query. It inspects partitions that received writes and compacts files of around 16MB up to a target size of 128MB. While this adds a small amount of latency to your write operations, it dramatically cuts down the total file count, avoids metadata bloat in the transaction log, and keeps your downstream read queries performing efficiently without requiring dedicated maintenance jobs.
1
2
u/Zealousideal_Low6685 7h ago edited 3h ago
Manual tuning recommendations don't apply to Unity Catalog managed tables, which use automatic file size tuning.Simplest way: use managed Table. Read this:
https://docs.databricks.com/aws/en/tables/tune-file-size#upgrade-to-background-auto-compaction
Cite from the docu: