Cloud Technology

How do I effectively manage small file problems in Databricks using Delta Lake features?

SA Asked by Sarah Jenkins · 14-03-2025
0 upvotes 12,539 views 0 comments
The question

I am currently working on a streaming project in Databricks and noticing significant latency because of the "small file problem" in our Delta tables. Does anyone have a guide on how to implement Auto-Optimize or manual OPTIMIZE commands effectively without killing the cluster performance during peak hours?

3 answers

0
EM
Answered on 16-03-2025

To handle small files in Databricks, you should primarily look at the "Auto-Optimize" feature which includes optimized writes and auto-compaction. Optimized writes ensure that Databricks writes larger files during the initial ingestion phase, while auto-compaction runs a light-weight process to merge small files into larger ones after a write. For existing tables, running the OPTIMIZE command on a schedule during off-peak hours is best practice. You can also use Z-Ordering on frequently filtered columns to collocate related information, which significantly improves query skip performance.

0
MI
Answered on 18-03-2025

Have you considered if your partition strategy is contributing to the file fragmentation? Sometimes over-partitioning by a high-cardinality column like a timestamp or a unique ID creates thousands of tiny directories that the Spark engine struggles to scan efficiently.

RO 20-03-2025

You are spot on, Michael. I checked my schema and I was partitioning by 'transaction_hour' which created way too many small files per day. I’ve switched to partitioning by 'transaction_date' and let Databricks handle the sub-filtering. This change, combined with the OPTIMIZE command, reduced our metadata overhead by nearly 40% and improved our overall job stability.

0
JE
Answered on 21-03-2025

The simplest fix is enabling spark.databricks.delta.optimizeWrite.enabled in your cluster config. This ensures the engine re-partitions data before writing it to the storage layer.

SA 22-03-2025

I agree with Jessica; using the cluster-level configuration is a "set it and forget it" solution that works wonders for teams that don't want to manually trigger maintenance tasks.

Share your thoughts

Your email address will not be published. Required fields are marked (*)

Professional Counselling Session

Still have questions?
Schedule a free counselling session

Our experts are ready to help you with any questions about courses, admissions, or career paths. Get personalized guidance from industry professionals.

Request a Call Back

Search Online

We Accept

We Accept

Follow Us

"PMI®", "PMBOK®", "PMP®", "CAPM®" and "PMI-ACP®" are registered marks of the Project Management Institute, Inc. | "CSM", "CST" are Registered Trade Marks of The Scrum Alliance, USA. | COBIT® is a trademark of ISACA® registered in the United States and other countries.

Book Free Session