Skip to content

Commit 0ee9a68

Browse files
committed
syn2mas: improve performance of reading access tokens / refresh tokens
1 parent f5b17d9 commit 0ee9a68

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
@@ -449,7 +449,7 @@ impl<'conn> SynapseReader<'conn> {
449449
INNER JOIN devices USING (user_id, device_id)
450450
WHERE at0.puppets_user_id IS NULL AND at0.refresh_token_id IS NULL
451451
452-
UNION
452+
UNION ALL
453453
454454
SELECT
455455
at0.user_id, at0.device_id, at0.token, at0.valid_until_ms, at0.last_validated
@@ -478,7 +478,7 @@ impl<'conn> SynapseReader<'conn> {
478478
SELECT
479479
rt0.user_id, rt0.device_id, at0.token AS access_token, rt0.token AS refresh_token, at0.valid_until_ms, at0.last_validated
480480
FROM refresh_tokens rt0
481-
INNER JOIN devices USING (device_id)
481+
INNER JOIN devices USING (user_id, device_id)
482482
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
483483
LEFT JOIN access_tokens at1 ON at1.refresh_token_id = rt0.next_token_id
484484
WHERE NOT at1.used OR at1.used IS NULL

0 commit comments

Comments
 (0)