🗄️File Compaction
Also known as Table Compaction, Small File Compaction, Bin-Packing
Packing lots of small files into a few big ones. Reads get fast.
Think of it like
It is like putting a pile of loose photos in one book. Now there is just one thing to pick up.
Example
A team compacts its events table each night. About 260,000 small files become 400 large ones, and the morning report takes seconds, not minutes.
Why it matters
It is the standard fix for the small files problem. Without it, a busy lake table gets slower every week.
Definition
Example code
sql
OPTIMIZE events WHERE event_date >= '2026-11-01';Common mistake
Key takeaways
- 1Same rows. Only the packing changes.
- 2Fewer files. Fewer opens per query.
- 3Run often. Usually each night, on new data.