diff --git a/changelog.d/13771.doc b/changelog.d/13771.doc new file mode 100644 index 000000000000..f45b5dc1bbd8 --- /dev/null +++ b/changelog.d/13771.doc @@ -0,0 +1 @@ +Document easy room purge benefit of using `(room_id, event_id)` in our database schemas. diff --git a/docs/development/database_schema.md b/docs/development/database_schema.md index e9b925ddd835..9648a939b76f 100644 --- a/docs/development/database_schema.md +++ b/docs/development/database_schema.md @@ -208,10 +208,12 @@ But hash collisions are still possible, and by treating event IDs as room scoped, we can reduce the possibility of a hash collision. When scoping `event_id` in the database schema, it should be also accompanied by `room_id` (`PRIMARY KEY (room_id, event_id)`) and lookups should be done through the pair -`(room_id, event_id)`. +`(room_id, event_id)`. Another benefit of scoping `event_ids` to the room is +that it makes it very easy to find and clean up everything in a room when it +needs to be purged (no need to use sub-`select` query or join from the `events` +table). -There has been a lot of debate on this in places like +`event_id` global uniqueness has had a lot debate in places like https://github.com/matrix-org/matrix-spec-proposals/issues/2779 and [MSC2848](https://github.com/matrix-org/matrix-spec-proposals/pull/2848) which has no resolution yet (as of 2022-09-01). -