Skip to content

Commit ba9e8bc

Browse files
reivilibresandhose
authored andcommitted
syn2mas: improve performance of reading access tokens / refresh tokens
1 parent 5302a6d commit ba9e8bc

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
@@ -498,7 +498,7 @@ impl<'conn> SynapseReader<'conn> {
498498
INNER JOIN devices USING (user_id, device_id)
499499
WHERE at0.puppets_user_id IS NULL AND at0.refresh_token_id IS NULL
500500
501-
UNION
501+
UNION ALL
502502
503503
SELECT
504504
at0.user_id, at0.device_id, at0.token, at0.valid_until_ms, at0.last_validated
@@ -527,7 +527,7 @@ impl<'conn> SynapseReader<'conn> {
527527
SELECT
528528
rt0.user_id, rt0.device_id, at0.token AS access_token, rt0.token AS refresh_token, at0.valid_until_ms, at0.last_validated
529529
FROM refresh_tokens rt0
530-
INNER JOIN devices USING (device_id)
530+
INNER JOIN devices USING (user_id, device_id)
531531
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
532532
LEFT JOIN access_tokens at1 ON at1.refresh_token_id = rt0.next_token_id
533533
WHERE NOT at1.used OR at1.used IS NULL

0 commit comments

Comments
 (0)