GetEmailCount Endpoint: Added GET /api/emails/count for fast, server-side unread and folder badge evaluation without loading standard arrays.GetAccountIDsByFilter Strategy: Multi-account mapping for context-aware background execution during unified bulk updates.lastUID=0), an isolated descending query pulls 200 fresh items to populate the UI instantly. Historical sync then processes remaining emails in an ascending loop (1 → UIDNext), incrementally locking the lastUID high-watermark.RUN --mount=type=cache...) across internal environments, shrinking image compilation stages from 330 seconds down to 30–60 seconds.GetGroups that executed dynamic counts over the emails table N times (forcing 750K+ rows scanned on production) with a unified LEFT JOIN and an optimized COUNT(e.id) FILTER (WHERE...) aggregation block. Drops complexity from O(N×M) to a single-pass O(M) hash join across PostgreSQL and SQLite backends.shiftPGPlaceholders Target Shifting: Replaced raw incremental parameter substitution loops with an intermediate marker mapping pattern ($10 → __PGH__11__ → $11). Eliminates variable corruption vectors across long dynamic query strings.CREATE INDEX CONCURRENTLY operations to synchronous schema specifications to bypass structural partitioning restrictions in PostgreSQL. Moved InitSchema execution blocks to independent background goroutines to prevent initial startup locking.FetchMessageBuffer heap growth across 250,000+ item iterations.useEffect bindings from dynamic data states to specific mutation invalidation loops (unreadRefetchTrigger), terminating recursive client polling overhead.snooze_until filtering matrices across core analytical subqueries in both database engines, establishing strict list-to-badge structural parity.UIDValidity Data Drops: Forced immediate database updates of evaluated folder metrics prior to early state breaks, preventing accidental fallback sweeps.