Skip to content

Commit

Permalink
crypto/sqlstore: add index to crypto_olm_sessions table to speed up l…
Browse files Browse the repository at this point in the history
…ookups by sender_key (#323)

Co-authored-by: Tulir Asokan <[email protected]>
  • Loading branch information
bradtgmurray and tulir authored Nov 26, 2024
1 parent f7e5f0a commit 4b970e0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crypto/sql_store_upgrade/00-latest-revision.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- v0 -> v15: Latest revision
-- v0 -> v16 (compatible with v15+): Latest revision
CREATE TABLE IF NOT EXISTS crypto_account (
account_id TEXT PRIMARY KEY,
device_id TEXT NOT NULL,
Expand Down Expand Up @@ -43,6 +43,7 @@ CREATE TABLE IF NOT EXISTS crypto_olm_session (
last_encrypted timestamp NOT NULL,
PRIMARY KEY (account_id, session_id)
);
CREATE INDEX crypto_olm_session_sender_key_idx ON crypto_olm_session (account_id, sender_key);

CREATE TABLE IF NOT EXISTS crypto_megolm_inbound_session (
account_id TEXT,
Expand Down
2 changes: 2 additions & 0 deletions crypto/sql_store_upgrade/16-crypto-olm-sessions-index.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- v16 (compatible with v15+): Add index to crypto_olm_sessions to speedup lookups by sender_key
CREATE INDEX crypto_olm_session_sender_key_idx ON crypto_olm_session (account_id, sender_key);

0 comments on commit 4b970e0

Please sign in to comment.