Skip to content

Commit 79323a5

Browse files
reivilibresandhose
authored andcommitted
syn2mas: improve performance of reading access tokens / refresh tokens
1 parent 587dcf5 commit 79323a5

File tree

1 file changed

+2
-2
lines changed
  • crates/syn2mas/src/synapse_reader

1 file changed

+2
-2
lines changed

crates/syn2mas/src/synapse_reader/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ impl<'conn> SynapseReader<'conn> {
511511
INNER JOIN devices USING (user_id, device_id)
512512
WHERE at0.puppets_user_id IS NULL AND at0.refresh_token_id IS NULL
513513
514-
UNION
514+
UNION ALL
515515
516516
SELECT
517517
at0.user_id, at0.device_id, at0.token, at0.valid_until_ms, at0.last_validated
@@ -540,7 +540,7 @@ impl<'conn> SynapseReader<'conn> {
540540
SELECT
541541
rt0.user_id, rt0.device_id, at0.token AS access_token, rt0.token AS refresh_token, at0.valid_until_ms, at0.last_validated
542542
FROM refresh_tokens rt0
543-
INNER JOIN devices USING (device_id)
543+
INNER JOIN devices USING (user_id, device_id)
544544
INNER JOIN access_tokens at0 ON at0.refresh_token_id = rt0.id AND at0.user_id = rt0.user_id AND at0.device_id = rt0.device_id
545545
LEFT JOIN access_tokens at1 ON at1.refresh_token_id = rt0.next_token_id
546546
WHERE NOT at1.used OR at1.used IS NULL

0 commit comments

Comments
 (0)