Add an index to make membership queries faster #1867

Merged
merged 1 commit into from Feb 1, 2017

Projects

None yet

2 participants

@erikjohnston
Member

No description provided.

@erikjohnston erikjohnston Add an index to make membership queries faster
21b7375
+ self.CURRENT_STATE_INDEX_UPDATE_NAME,
+ index_name="current_state_events_member_index",
+ table="current_state_events",
+ columns=["state_key"],
@NegativeMjark
NegativeMjark Feb 1, 2017 Contributor

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

@NegativeMjark
NegativeMjark Feb 1, 2017 edited Contributor

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

@erikjohnston
erikjohnston Feb 1, 2017 Member

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.

@NegativeMjark
NegativeMjark Feb 1, 2017 Contributor

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

@NegativeMjark

LGTM

@erikjohnston erikjohnston merged commit 88a4d54 into develop Feb 1, 2017

8 checks passed

Sytest Dendron (Commit) Build #1450 origin/erikj/member_index succeeded in 10 min
Details
Sytest Dendron (Merged PR) Build finished.
Details
Sytest Postgres (Commit) Build #2267 origin/erikj/member_index succeeded in 5 min 44 sec
Details
Sytest Postgres (Merged PR) Build finished.
Details
Sytest SQLite (Commit) Build #2336 origin/erikj/member_index succeeded in 5 min 57 sec
Details
Sytest SQLite (Merged PR) Build finished.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment