#13457·polar

Make email deduplication more robust

Author: joebonCreated Jul 30, 2026Updated Aug 19, 2026

Email deduplication (used to avoid sending the same email multiple times when for instance sending reminder emails) is currently brittle and unoptimized:

  • Uses non-indexed metadata on email_logs table to figure out if email has already been sent

Should reasonably be fixed in a 3-step rollout:

  1. Add a nullable deduplication key column to email_logs, along with code that populates it for new emails and with a backfill script. Nullable should be kept because not all emails require a deduplication key
  2. Add a partial unique index
  3. Switch from the current checking to checking the new key