AFTER: HISTORY API INCREMENTAL SYNC
Optimized Gmail Sync Architecture
1
history.list — Fetch only changes since last sync
Returns 2-5 changes instead of re-fetching 100 messages
2
messages.get x 3 — Fetch only new messages
Only fetch content for messages that actually changed
3
Batch upsert — Single database write
INSERT ... ON CONFLICT with multiple value tuples in one query
67x faster
47s → 0.7s for typical sync cycle