R2 Data Catalog
Automatic Table MaintenanceR2 Data Catalog
Cloudflare

Keep Tables Fast Without Lifting a Finger

Streaming ingest creates many small files. Without maintenance, queries slow down as file count grows. R2 Data Catalog automates the two most critical operations.

Auto Compaction

Merges small data files into larger, optimized files. Reduces file count, improves query speed, and increases compression efficiency.

Target file size: 64 MB - 512 MB
Compacts up to 2 GB per table per hour
Runs automatically, no manual triggers needed

Snapshot Expiration

Removes old table snapshots to reduce metadata bloat and storage costs while preserving recent history.

Configure max age (e.g., 7 days)
Retain minimum snapshot count (e.g., 10)
Both conditions must be met to expire
Query Performance Impact
Before200 small files
4-9 seconds per query
After10 compacted files
1-3 seconds per query
Enable maintenance
# Enable compaction (target 128 MB files)
npx wrangler r2 bucket catalog compaction enable \
my-bucket --target-size 128 --token $TOKEN
# Enable snapshot expiration
npx wrangler r2 bucket catalog snapshot-expiration \
enable my-bucket --older-than-days 7 \
--retain-last 10 --token $TOKEN
10 / 12