diff --git a/internal/db/schema/migrations/oss/postgres/80/09_host_table_updates.up.sql b/internal/db/schema/migrations/oss/postgres/80/09_host_table_updates.up.sql new file mode 100644 index 000000000..cccf646a1 --- /dev/null +++ b/internal/db/schema/migrations/oss/postgres/80/09_host_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_host_create_time_public_id_idx + on host_plugin_host (create_time desc, public_id asc); + create index host_plugin_host_update_time_public_id_idx + on host_plugin_host (update_time desc, public_id asc); + + 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); + create index static_host_update_time_public_id_idx + on static_host (update_time desc, public_id asc); + + analyze static_host; + +commit; diff --git a/internal/db/sqltest/tests/pagination/host.sql b/internal/db/sqltest/tests/pagination/host.sql new file mode 100644 index 000000000..fab9f8b01 --- /dev/null +++ b/internal/db/sqltest/tests/pagination/host.sql @@ -0,0 +1,15 @@ +-- Copyright (c) HashiCorp, Inc. +-- SPDX-License-Identifier: BUSL-1.1 + +begin; + select plan(4); + + select has_index('host_plugin_host', 'host_plugin_host_create_time_public_id_idx', array['create_time', 'public_id']); + select has_index('host_plugin_host', 'host_plugin_host_update_time_public_id_idx', array['update_time', 'public_id']); + + select has_index('static_host', 'static_host_create_time_public_id_idx', array['create_time', 'public_id']); + select has_index('static_host', 'static_host_update_time_public_id_idx', array['update_time', 'public_id']); + + select * from finish(); + +rollback;