internal/authtoken: sort public_id descending
The previous sort would run the risk of missing items which collide on update or create times because of the compound comparison using strictly less than for both the timestamp and the public_id. Sorting both descending avoids thi issue.
This commit is contained in:
1 parent
d4d1efce93
commit
f9950a7e1c
2 files changed
+11
-11
No files matched your search
@@ -17,7 +17,7 @@ with auth_tokens as (
|
||||
expiration_time,
|
||||
status
|
||||
from auth_token
|
||||
order by create_time desc, public_id asc
|
||||
order by create_time desc, public_id desc
|
||||
limit %d
|
||||
),
|
||||
auth_accounts as (
|
||||
@@ -47,7 +47,7 @@ final as (
|
||||
)
|
||||
select *
|
||||
from final
|
||||
order by create_time desc, public_id asc;
|
||||
order by create_time desc, public_id desc;
|
||||
`
|
||||
listAuthTokensPageTemplate = `
|
||||
with auth_tokens as (
|
||||
@@ -60,7 +60,7 @@ with auth_tokens as (
|
||||
status
|
||||
from auth_token
|
||||
where (create_time, public_id) < (@last_item_create_time, @last_item_id)
|
||||
order by create_time desc, public_id asc
|
||||
order by create_time desc, public_id desc
|
||||
limit %d
|
||||
),
|
||||
auth_accounts as (
|
||||
@@ -90,7 +90,7 @@ final as (
|
||||
)
|
||||
select *
|
||||
from final
|
||||
order by create_time desc, public_id asc;
|
||||
order by create_time desc, public_id desc;
|
||||
`
|
||||
refreshAuthTokensTemplate = `
|
||||
with auth_tokens as (
|
||||
@@ -103,7 +103,7 @@ with auth_tokens as (
|
||||
status
|
||||
from auth_token
|
||||
where update_time > @updated_after_time
|
||||
order by update_time desc, public_id asc
|
||||
order by update_time desc, public_id desc
|
||||
limit %d
|
||||
),
|
||||
auth_accounts as (
|
||||
@@ -133,7 +133,7 @@ final as (
|
||||
)
|
||||
select *
|
||||
from final
|
||||
order by update_time desc, public_id asc;
|
||||
order by update_time desc, public_id desc;
|
||||
`
|
||||
refreshAuthTokensPageTemplate = `
|
||||
with auth_tokens as (
|
||||
@@ -147,7 +147,7 @@ with auth_tokens as (
|
||||
from auth_token
|
||||
where update_time > @updated_after_time
|
||||
and (update_time, public_id) < (@last_item_update_time, @last_item_id)
|
||||
order by update_time desc, public_id asc
|
||||
order by update_time desc, public_id desc
|
||||
limit %d
|
||||
),
|
||||
auth_accounts as (
|
||||
@@ -177,6 +177,6 @@ final as (
|
||||
)
|
||||
select *
|
||||
from final
|
||||
order by update_time desc, public_id asc;
|
||||
order by update_time desc, public_id desc;
|
||||
`
|
||||
)
|
||||
+3
-3
@@ -5,10 +5,10 @@ begin;
|
||||
|
||||
-- Add new indexes for the create time and update time queries.
|
||||
create index auth_token_create_time_public_id_idx
|
||||
on auth_token (create_time desc, public_id asc);
|
||||
on auth_token (create_time desc, public_id desc);
|
||||
create index auth_token_update_time_public_id_idx
|
||||
on auth_token (update_time desc, public_id asc);
|
||||
on auth_token (update_time desc, public_id desc);
|
||||
|
||||
analyze auth_token;
|
||||
|
||||
commit;
|
||||
commit;
|
||||
Reference in new issue
Block a user