diff --git a/internal/db/schema/migrations/oss/postgres/80/10_host_set_table_updates.up.sql b/internal/db/schema/migrations/oss/postgres/80/10_host_set_table_updates.up.sql new file mode 100644 index 0000000000..ca8f8eabb6 --- /dev/null +++ b/internal/db/schema/migrations/oss/postgres/80/10_host_set_table_updates.up.sql @@ -0,0 +1,22 @@ +-- Copyright (c) HashiCorp, Inc. +-- SPDX-License-Identifier: BUSL-1.1 + +begin; + + -- Add new indexes for the create time and update time queries. + create index host_plugin_set_create_time_public_id_idx + on host_plugin_set (create_time desc, public_id asc); + create index host_plugin_set_update_time_public_id_idx + on host_plugin_set (update_time desc, public_id asc); + + analyze host_plugin_set; + + -- Add new indexes for the create time and update time queries. + create index static_host_set_create_time_public_id_idx + on static_host_set (create_time desc, public_id asc); + create index static_host_set_update_time_public_id_idx + on static_host_set (update_time desc, public_id asc); + + analyze static_host_set; + +commit; diff --git a/internal/db/sqltest/tests/pagination/host_set.sql b/internal/db/sqltest/tests/pagination/host_set.sql new file mode 100644 index 0000000000..78834222e4 --- /dev/null +++ b/internal/db/sqltest/tests/pagination/host_set.sql @@ -0,0 +1,15 @@ +-- Copyright (c) HashiCorp, Inc. +-- SPDX-License-Identifier: BUSL-1.1 + +begin; + select plan(4); + + select has_index('host_plugin_set', 'host_plugin_set_create_time_public_id_idx', array['create_time', 'public_id']); + select has_index('host_plugin_set', 'host_plugin_set_update_time_public_id_idx', array['update_time', 'public_id']); + + select has_index('static_host_set', 'static_host_set_create_time_public_id_idx', array['create_time', 'public_id']); + select has_index('static_host_set', 'static_host_set_update_time_public_id_idx', array['update_time', 'public_id']); + + select * from finish(); + +rollback;