internal/target: 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
3bf925ca32
commit
fc9b26efa7
2 files changed
+10
-10
No files matched your search
@@ -36,9 +36,9 @@ begin;
|
||||
|
||||
-- Add new indexes for the update time queries.
|
||||
create index target_create_time_public_id_idx
|
||||
on target (create_time desc, public_id asc);
|
||||
on target (create_time desc, public_id desc);
|
||||
create index target_update_time_public_id_idx
|
||||
on target (update_time desc, public_id asc);
|
||||
on target (update_time desc, public_id desc);
|
||||
|
||||
analyze target;
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ with targets as (
|
||||
select public_id
|
||||
from target
|
||||
where %s -- search condition for applying permissions is constructed
|
||||
order by create_time desc, public_id asc
|
||||
order by create_time desc, public_id desc
|
||||
limit %d
|
||||
),
|
||||
tcp_targets as (
|
||||
@@ -122,7 +122,7 @@ final as (
|
||||
)
|
||||
select *
|
||||
from final
|
||||
order by create_time desc, public_id asc;
|
||||
order by create_time desc, public_id desc;
|
||||
`
|
||||
|
||||
listTargetsPageTemplate = `
|
||||
@@ -131,7 +131,7 @@ with targets as (
|
||||
from target
|
||||
where (create_time, public_id) < (@last_item_create_time, @last_item_id)
|
||||
and %s -- search condition for applying permissions is constructed
|
||||
order by create_time desc, public_id asc
|
||||
order by create_time desc, public_id desc
|
||||
limit %d
|
||||
),
|
||||
tcp_targets as (
|
||||
@@ -185,7 +185,7 @@ final as (
|
||||
)
|
||||
select *
|
||||
from final
|
||||
order by create_time desc, public_id asc;
|
||||
order by create_time desc, public_id desc;
|
||||
`
|
||||
|
||||
refreshTargetsTemplate = `
|
||||
@@ -194,7 +194,7 @@ with targets as (
|
||||
from target
|
||||
where update_time > @updated_after_time
|
||||
and %s -- search condition for applying permissions is constructed
|
||||
order by update_time desc, public_id asc
|
||||
order by update_time desc, public_id desc
|
||||
limit %d
|
||||
),
|
||||
tcp_targets as (
|
||||
@@ -248,7 +248,7 @@ final as (
|
||||
)
|
||||
select *
|
||||
from final
|
||||
order by update_time desc, public_id asc;
|
||||
order by update_time desc, public_id desc;
|
||||
`
|
||||
|
||||
refreshTargetsPageTemplate = `
|
||||
@@ -258,7 +258,7 @@ with targets as (
|
||||
where update_time > @updated_after_time
|
||||
and (update_time, public_id) < (@last_item_update_time, @last_item_id)
|
||||
and %s -- search condition for applying permissions is constructed
|
||||
order by update_time desc, public_id asc
|
||||
order by update_time desc, public_id desc
|
||||
limit %d
|
||||
),
|
||||
tcp_targets as (
|
||||
@@ -312,6 +312,6 @@ final as (
|
||||
)
|
||||
select *
|
||||
from final
|
||||
order by update_time desc, public_id asc;
|
||||
order by update_time desc, public_id desc;
|
||||
`
|
||||
)
|
||||
Reference in new issue
Block a user