Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add an index to make membership queries faster #1867

Merged
merged 1 commit into from
Feb 1, 2017

Conversation

erikjohnston
Copy link
Member

No description provided.

self.CURRENT_STATE_INDEX_UPDATE_NAME,
index_name="current_state_events_member_index",
table="current_state_events",
columns=["state_key"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be ["room_id", "state_key"]?

Copy link
Contributor

@NegativeMjark NegativeMjark Feb 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, this for rooms_for_user so you want to look up by user_id = state_key.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No because we're looking up the room. The query we're optimising is essentially:

SELECT * FROM current_state_events WHERE type = 'm.room.member' AND state_key = ?

The type is in the where clause.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the users_in_room is already handled by the (room_id, type, state_key) index.

Copy link
Contributor

@NegativeMjark NegativeMjark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@erikjohnston erikjohnston merged commit 88a4d54 into develop Feb 1, 2017
@erikjohnston erikjohnston deleted the erikj/member_index branch March 29, 2017 10:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants