Skip to content

perf(campaigns): standardize queries for listed statuses - #197

Open
ajohn25 wants to merge 1 commit into
dialerfrom
perf-campaign-filters
Open

perf(campaigns): standardize queries for listed statuses#197
ajohn25 wants to merge 1 commit into
dialerfrom
perf-campaign-filters

Conversation

@ajohn25

@ajohn25 ajohn25 commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

Description

This makes a few changes to boost performance for loading campaign statuses:

  1. Tweaking use of campaign_contact.archived to only filter when partial index usage is likely
  • When archived status is known (ex. when a filter is applied), compare the known value directly with campaign_contact.archived, to improve chance of index usage
  • When archived status is unknown, don't use campaign_contact.archived at all. The partial index is unlikely to be used in this case, and the trigger on campaign archiving already guarantees that campaign_contact.archived = campaign.is_archived
  1. Dropping checks for escalated / unassignable tags
  • These were previously inconsistent ( getHasUnassignedContacts used assignable, getHasUnhandledMessages used escalated)
  • Checking against these doesn't make a ton of sense. As an admin, I want to know about unassigned contacts + unhandled messages especially if they can't be assigned to regular texters - it means I should pay closer attention to those

Motivation and Context

Performance + readability

While this is rebased off dialer so that related queries are also refactored, no need to review till after dialer sprint.

How Has This Been Tested?

This has been tested locally

Claude generated SQL output can be found here

Screenshots (if appropriate):

Documentation Changes

Checklist:

  • My change requires a change to the documentation.
  • I have included updates for the documentation accordingly.

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