Skip to content

perf: prefer campaign contact archived checks over campaign - #244

Open
ajohn25 wants to merge 1 commit into
mainfrom
chore/drop-redundant-is-archived-checks
Open

perf: prefer campaign contact archived checks over campaign#244
ajohn25 wants to merge 1 commit into
mainfrom
chore/drop-redundant-is-archived-checks

Conversation

@ajohn25

@ajohn25 ajohn25 commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • campaign_contact.archived is kept in sync with campaign.is_archived, so several queries were doing redundant work by also joining to / filtering on campaign.is_archived.
  • sendMessage: removed the redundant campaign.is_archived where-clause (already covered by campaign_contact.archived = false) and the unused is_archived select alias.
  • removeOptOut: dropped the leftJoin to campaign — it existed solely to filter is_archived, which campaign_contact.archived already gives us directly.
  • releaseMessages: dropped the unnecessary campaign join in the raw UPDATE ... FROM clause — the is_archived value is already substituted as a literal from a separate lookup, and no other campaign column was used.

Test plan

  • yarn test (send-message / root-mutations specs)
  • Manually opt a contact back in via Admin → Incoming Message List (removeOptOut path)
  • Manually run "Release Unsent Messages" / "Release Unreplied Conversations" from Admin → Campaign List (releaseMessages path)
  • Send a message as a texter (sendMessage path)

🤖 Generated with Claude Code

campaign_contact.archived is kept in sync with campaign.is_archived, so
filtering on both (or joining to campaign solely to read is_archived) is
dead weight. Removes an unused select in sendMessage, an unnecessary
leftJoin in removeOptOut, and an unnecessary join in the releaseMessages
raw update.
@ajohn25 ajohn25 changed the title chore(db): drop redundant campaign.is_archived checks/joins perf: prefer campaign contact archived checks over campaign Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant