internal/host: 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
d4f5677858
commit
d94a25bbd2
3 files changed
+20
-20
No files matched your search
@@ -5,17 +5,17 @@ begin;
|
||||
|
||||
-- Add new indexes for the create time and update time queries.
|
||||
create index host_plugin_host_create_time_public_id_idx
|
||||
on host_plugin_host (create_time desc, public_id asc);
|
||||
on host_plugin_host (create_time desc, public_id desc);
|
||||
create index host_plugin_host_update_time_public_id_idx
|
||||
on host_plugin_host (update_time desc, public_id asc);
|
||||
on host_plugin_host (update_time desc, public_id desc);
|
||||
|
||||
analyze host_plugin_host;
|
||||
|
||||
-- Add new indexes for the create time and update time queries.
|
||||
create index static_host_create_time_public_id_idx
|
||||
on static_host (create_time desc, public_id asc);
|
||||
on static_host (create_time desc, public_id desc);
|
||||
create index static_host_update_time_public_id_idx
|
||||
on static_host (update_time desc, public_id asc);
|
||||
on static_host (update_time desc, public_id desc);
|
||||
|
||||
analyze static_host;
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ with hosts as (
|
||||
version
|
||||
from host_plugin_host
|
||||
where catalog_id = @catalog_id
|
||||
order by create_time desc, public_id asc
|
||||
order by create_time desc, public_id desc
|
||||
limit %d
|
||||
),
|
||||
host_catalog as (
|
||||
@@ -126,7 +126,7 @@ final as (
|
||||
)
|
||||
select *
|
||||
from final
|
||||
order by create_time desc, public_id asc;
|
||||
order by create_time desc, public_id desc;
|
||||
`
|
||||
|
||||
listHostsPageTemplate = `
|
||||
@@ -143,7 +143,7 @@ with hosts as (
|
||||
from host_plugin_host
|
||||
where catalog_id = @catalog_id
|
||||
and (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
|
||||
),
|
||||
host_catalog as (
|
||||
@@ -197,7 +197,7 @@ final as (
|
||||
)
|
||||
select *
|
||||
from final
|
||||
order by create_time desc, public_id asc;
|
||||
order by create_time desc, public_id desc;
|
||||
`
|
||||
|
||||
listHostsRefreshTemplate = `
|
||||
@@ -214,7 +214,7 @@ with hosts as (
|
||||
from host_plugin_host
|
||||
where catalog_id = @catalog_id
|
||||
and update_time > @updated_after_time
|
||||
order by update_time desc, public_id asc
|
||||
order by update_time desc, public_id desc
|
||||
limit %d
|
||||
),
|
||||
host_catalog as (
|
||||
@@ -268,7 +268,7 @@ final as (
|
||||
)
|
||||
select *
|
||||
from final
|
||||
order by update_time desc, public_id asc;
|
||||
order by update_time desc, public_id desc;
|
||||
`
|
||||
|
||||
listHostsRefreshPageTemplate = `
|
||||
@@ -286,7 +286,7 @@ with hosts as (
|
||||
where catalog_id = @catalog_id
|
||||
and 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
|
||||
),
|
||||
host_catalog as (
|
||||
@@ -340,7 +340,7 @@ final as (
|
||||
)
|
||||
select *
|
||||
from final
|
||||
order by update_time desc, public_id asc;
|
||||
order by update_time desc, public_id desc;
|
||||
`
|
||||
|
||||
estimateCountHostSets = `
|
||||
|
||||
@@ -63,7 +63,7 @@ with hosts as (
|
||||
version
|
||||
from static_host
|
||||
where catalog_id = @catalog_id
|
||||
order by create_time desc, public_id asc
|
||||
order by create_time desc, public_id desc
|
||||
limit %d
|
||||
),
|
||||
host_set_ids as (
|
||||
@@ -88,7 +88,7 @@ final as (
|
||||
)
|
||||
select *
|
||||
from final
|
||||
order by create_time desc, public_id asc;
|
||||
order by create_time desc, public_id desc;
|
||||
`
|
||||
|
||||
listHostsPageTemplate = `
|
||||
@@ -104,7 +104,7 @@ with hosts as (
|
||||
from static_host
|
||||
where catalog_id = @catalog_id
|
||||
and (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
|
||||
),
|
||||
host_set_ids as (
|
||||
@@ -129,7 +129,7 @@ final as (
|
||||
)
|
||||
select *
|
||||
from final
|
||||
order by create_time desc, public_id asc;
|
||||
order by create_time desc, public_id desc;
|
||||
`
|
||||
|
||||
listHostsRefreshTemplate = `
|
||||
@@ -145,7 +145,7 @@ with hosts as (
|
||||
from static_host
|
||||
where catalog_id = @catalog_id
|
||||
and update_time > @updated_after_time
|
||||
order by update_time desc, public_id asc
|
||||
order by update_time desc, public_id desc
|
||||
limit %d
|
||||
),
|
||||
host_set_ids as (
|
||||
@@ -170,7 +170,7 @@ final as (
|
||||
)
|
||||
select *
|
||||
from final
|
||||
order by update_time desc, public_id asc;
|
||||
order by update_time desc, public_id desc;
|
||||
`
|
||||
listHostsRefreshPageTemplate = `
|
||||
with hosts as (
|
||||
@@ -186,7 +186,7 @@ with hosts as (
|
||||
where catalog_id = @catalog_id
|
||||
and 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
|
||||
),
|
||||
host_set_ids as (
|
||||
@@ -211,7 +211,7 @@ final as (
|
||||
)
|
||||
select *
|
||||
from final
|
||||
order by update_time desc, public_id asc;
|
||||
order by update_time desc, public_id desc;
|
||||
`
|
||||
|
||||
estimateCountHostSets = `
|
||||
|
||||
Reference in new issue
Block a user