perf(sync): batch new-message detection to remove the is_new_message N+1 #341

Merged
KofTwentyTwo merged 1 commits from story/ws-f5-is-new-message-batch into dev 2026-07-31 19:11:05 +00:00
1 Commits
Author SHA1 Message Date
James Maes a0d8b4b168 perf(sync): batch new-message detection to remove the is_new_message N+1
Replace the per-message get_message existence check in fetch_and_persist
with a single existing_message_ids(chunk_ids) lookup per fetched folder
chunk, plus a per-pass seen-set to keep duplicate ids within one chunk
firing at most once. Fire-once semantics for filter actions are
unchanged: a message is new iff it was absent from the store before this
sync pass and this is its first occurrence in the current chunk.

Refs #325
2026-07-31 14:07:49 -05:00