This repository was archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Postgres indexes differ on matrix.org #11893
Copy link
Copy link
Open
Labels
A-DatabaseDB stuff like queries, migrations, new/remove columns, indexes, unexpected entries in the dbDB stuff like queries, migrations, new/remove columns, indexes, unexpected entries in the dbO-UncommonMost users are unlikely to come across this or unexpected workflowMost users are unlikely to come across this or unexpected workflowS-TolerableMinor significance, cosmetic issues, low or no impact to users.Minor significance, cosmetic issues, low or no impact to users.T-TaskRefactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.Z-CleanupThings we want to get rid of, but aren't actively causing painThings we want to get rid of, but aren't actively causing painZ-Dev-WishlistMakes developers' lives better, but doesn't have direct user impactMakes developers' lives better, but doesn't have direct user impact
Description
matrix.org seems to have different indexes for the event_push_actions
than what is available via the Synapse distribution. I'm unsure how/why these appeared, but we should investigate and make them consistent with what is available in-repo.
Fresh database:
# SELECT indexname, indexdef FROM pg_indexes WHERE tablename = 'event_push_actions' ORDER BY indexname;
indexname | indexdef
-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
event_id_user_id_profile_tag_uniqueness | CREATE UNIQUE INDEX event_id_user_id_profile_tag_uniqueness ON event_push_actions USING btree (room_id, event_id, user_id, profile_tag)
event_push_actions_highlights_index | CREATE INDEX event_push_actions_highlights_index ON event_push_actions USING btree (user_id, room_id, topological_ordering, stream_ordering) WHERE (highlight = 1)
event_push_actions_rm_tokens | CREATE INDEX event_push_actions_rm_tokens ON event_push_actions USING btree (user_id, room_id, topological_ordering, stream_ordering)
event_push_actions_room_id_user_id | CREATE INDEX event_push_actions_room_id_user_id ON event_push_actions USING btree (room_id, user_id)
event_push_actions_stream_ordering | CREATE INDEX event_push_actions_stream_ordering ON event_push_actions USING btree (stream_ordering, user_id)
event_push_actions_u_highlight | CREATE INDEX event_push_actions_u_highlight ON event_push_actions USING btree (user_id, stream_ordering)
matrix.org:
# SELECT indexname, indexdef FROM pg_indexes WHERE tablename = 'event_push_actions' ORDER BY indexname;
indexname | indexdef
-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
event_push_actions_highlights_index | CREATE INDEX event_push_actions_highlights_index ON event_push_actions USING btree (user_id, room_id, topological_ordering, stream_ordering) WHERE (highlight = 1)
event_push_actions_rm_id_ev_id | CREATE INDEX event_push_actions_rm_id_ev_id ON event_push_actions USING btree (room_id, event_id)
event_push_actions_rm_tokens | CREATE INDEX event_push_actions_rm_tokens ON event_push_actions USING btree (user_id, room_id, topological_ordering, stream_ordering)
event_push_actions_stream_ordering | CREATE INDEX event_push_actions_stream_ordering ON event_push_actions USING btree (stream_ordering, user_id)
event_push_actions_u_highlight | CREATE INDEX event_push_actions_u_highlight ON event_push_actions USING btree (user_id, stream_ordering, highlight)
Looking closely... the differences are:
--- fresh 2022-02-02 09:38:02.000000000 -0500
+++ matrixdotorg 2022-02-02 09:40:09.000000000 -0500
@@ -1,10 +1,9 @@
# SELECT indexname, indexdef FROM pg_indexes WHERE tablename = 'event_push_actions' ORDER BY indexname;
indexname | indexdef
-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- event_id_user_id_profile_tag_uniqueness | CREATE UNIQUE INDEX event_id_user_id_profile_tag_uniqueness ON event_push_actions USING btree (room_id, event_id, user_id, profile_tag)
event_push_actions_highlights_index | CREATE INDEX event_push_actions_highlights_index ON event_push_actions USING btree (user_id, room_id, topological_ordering, stream_ordering) WHERE (highlight = 1)
+ event_push_actions_rm_id_ev_id | CREATE INDEX event_push_actions_rm_id_ev_id ON event_push_actions USING btree (room_id, event_id)
event_push_actions_rm_tokens | CREATE INDEX event_push_actions_rm_tokens ON event_push_actions USING btree (user_id, room_id, topological_ordering, stream_ordering)
- event_push_actions_room_id_user_id | CREATE INDEX event_push_actions_room_id_user_id ON event_push_actions USING btree (room_id, user_id)
event_push_actions_stream_ordering | CREATE INDEX event_push_actions_stream_ordering ON event_push_actions USING btree (stream_ordering, user_id)
- event_push_actions_u_highlight | CREATE INDEX event_push_actions_u_highlight ON event_push_actions USING btree (user_id, stream_ordering)
+ event_push_actions_u_highlight | CREATE INDEX event_push_actions_u_highlight ON event_push_actions USING btree (user_id, stream_ordering, highlight)
Metadata
Metadata
Assignees
Labels
A-DatabaseDB stuff like queries, migrations, new/remove columns, indexes, unexpected entries in the dbDB stuff like queries, migrations, new/remove columns, indexes, unexpected entries in the dbO-UncommonMost users are unlikely to come across this or unexpected workflowMost users are unlikely to come across this or unexpected workflowS-TolerableMinor significance, cosmetic issues, low or no impact to users.Minor significance, cosmetic issues, low or no impact to users.T-TaskRefactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.Z-CleanupThings we want to get rid of, but aren't actively causing painThings we want to get rid of, but aren't actively causing painZ-Dev-WishlistMakes developers' lives better, but doesn't have direct user impactMakes developers' lives better, but doesn't have direct user impact