diff --git a/internal/db/schema/migrations/oss/postgres/80/05_session_base_table_updates.up.sql b/internal/db/schema/migrations/oss/postgres/80/05_session_base_table_updates.up.sql index 1bffedf3f..403b98667 100644 --- a/internal/db/schema/migrations/oss/postgres/80/05_session_base_table_updates.up.sql +++ b/internal/db/schema/migrations/oss/postgres/80/05_session_base_table_updates.up.sql @@ -5,10 +5,10 @@ begin; -- Add new indexes for the create time and update time queries. create index session_create_time_public_id_idx - on session (create_time desc, public_id asc); + on session (create_time desc, public_id desc); create index session_update_time_public_id_idx - on session (update_time desc, public_id asc); + on session (update_time desc, public_id desc); analyze session; -commit; \ No newline at end of file +commit; diff --git a/internal/session/query.go b/internal/session/query.go index e9c26b1b0..c16ecd0bb 100644 --- a/internal/session/query.go +++ b/internal/session/query.go @@ -429,13 +429,13 @@ with session_ids as ( from session -- search condition for applying permissions is constructed where %s - order by create_time desc, public_id asc + order by create_time desc, public_id desc limit %d ) select * from session_list where session_list.public_id in (select * from session_ids) - order by create_time desc, public_id asc; + order by create_time desc, public_id desc; ` listSessionsPageTemplate = ` with session_ids as ( @@ -444,13 +444,13 @@ with session_ids as ( where (create_time, public_id) < (@last_item_create_time, @last_item_id) -- search condition for applying permissions is constructed and %s - order by create_time desc, public_id asc + order by create_time desc, public_id desc limit %d ) select * from session_list where session_list.public_id in (select * from session_ids) - order by create_time desc, public_id asc; + order by create_time desc, public_id desc; ` refreshSessionsTemplate = ` with session_ids as ( @@ -459,13 +459,13 @@ with session_ids as ( where update_time > @updated_after_time -- search condition for applying permissions is constructed and %s - order by update_time desc, public_id asc + order by update_time desc, public_id desc limit %d ) select * from session_list where session_list.public_id in (select * from session_ids) -order by update_time desc, public_id asc; +order by update_time desc, public_id desc; ` refreshSessionsPageTemplate = ` with session_ids as ( @@ -475,13 +475,13 @@ with session_ids as ( and (update_time, public_id) < (@last_item_update_time, @last_item_id) -- search condition for applying permissions is constructed and %s - order by update_time desc, public_id asc + order by update_time desc, public_id desc limit %d ) select * from session_list where session_list.public_id in (select * from session_ids) -order by update_time desc, public_id asc; +order by update_time desc, public_id desc; ` estimateCountSessions = ` select reltuples::bigint as estimate from pg_class where oid in ('session'::regclass)