Skip to content

WPB-26823: make meetings cleanup fully index-driven#5328

Open
blackheaven wants to merge 7 commits into
developfrom
gdifolco/WPB-26823-meeting-index
Open

WPB-26823: make meetings cleanup fully index-driven#5328
blackheaven wants to merge 7 commits into
developfrom
gdifolco/WPB-26823-meeting-index

Conversation

@blackheaven

Copy link
Copy Markdown
Contributor

https://wearezeta.atlassian.net/browse/WPB-26823

Checklist

  • Add a new entry in an appropriate subdirectory of changelog.d
  • Read and follow the PR guidelines

Add two partial indexes and rewrite the meetings cleanup query so the
background worker stays fully index-driven as the meetings table grows:

- idx_meetings_recurrence_eff_end on GREATEST(end_time, recurrence_until)
  for bounded recurring meetings (recurring branches of list/cleanup queries).
- idx_meetings_end_time_nonrecurring on end_time for non-recurring meetings,
  so cleanup skips not-yet-expired recurring rows whose original slot is long
  past.

Rewrite getOldMeetingsImpl to issue one bounded, index-backed query per
meeting kind (non-recurring vs bounded recurring) and merge the batches in
Haskell, mirroring the in-memory store. (hasql-th rejects UNION ALL in a FROM
derived table, so the two statements are issued separately and merged.)

Both indexes are built CONCURRENTLY and registered in nonTransactionMigrations.

EXPLAIN ANALYZE on an adversarial data set (75k not-yet-expired recurring rows
with the oldest end_time, few expired rows) drops from 1661 buffers / 11.6ms /
75086 rows filtered to 9 buffers / 0.2ms / 0 filtered.

Follow-up to #5309 (discussion r3518905163).
@blackheaven blackheaven requested review from a team as code owners July 8, 2026 17:54
@zebot zebot added the ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist label Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants