Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a column
participant
toroom_memberships
table #18068base: develop
Are you sure you want to change the base?
Add a column
participant
toroom_memberships
table #18068Changes from 7 commits
afeed5b
754c27b
830e5e6
bc05f58
e76f94e
62e6a04
93e7a0c
115ff00
b0f804e
4e8dbd6
bc8f329
1539eb6
8b95806
3b9745d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that
room_memberships
is a table that is always be appended to, and thus always changing under you. It is ordered by itsevent_stream_ordering
column. So, the only way to traverse it while the system is running, without leaving gaps, is to iterate using theevent_stream_ordering
column.Note:
room_memberships
only has rows deleted from it when a room is purged.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently we have:
I think we can instead do this in one query that processes a batch of
room_membership
rows all at once. Instead of saving the currentroom_id
for the batch job, start with the currently maxevent_stream_ordering
row and work backwards in batches of say 1000.Constrain your query to the current
event_stream_ordering
-BATCH_SIZE
. Then within that, UPDATE all rows based on data in theevents
table. Then save the newevent_stream_ordering - BATCH_SIZE
to your background job.Now the table can continue to grow without things changing from underneath you, as historical data is only (rarely) deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking a look - I have rewritten the query as you requested. I did test it on a demo server with some trivial data and it worked, but do make sure I've got it correct as I don't often write SQL queries that aren't mostly simple.