From 5593a44802deadb979258c367d7c59140915d15f Mon Sep 17 00:00:00 2001 From: Sarah Botwinick Date: Tue, 12 Mar 2024 15:35:54 -0400 Subject: [PATCH] Add index for domainRepoId to PollMessage and DomainHistoryHost --- .../registry/model/domain/DomainHistory.java | 12 +++++++----- .../google/registry/model/poll/PollMessage.java | 7 ++++++- ...add_domain_repo_id_indexes_to_more_tables.sql | 16 ++++++++++++++++ .../resources/sql/schema/db-schema.sql.generated | 2 ++ 4 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 db/src/main/resources/sql/flyway/V161__add_domain_repo_id_indexes_to_more_tables.sql diff --git a/core/src/main/java/google/registry/model/domain/DomainHistory.java b/core/src/main/java/google/registry/model/domain/DomainHistory.java index 0e5f006d5..a3f60c2e7 100644 --- a/core/src/main/java/google/registry/model/domain/DomainHistory.java +++ b/core/src/main/java/google/registry/model/domain/DomainHistory.java @@ -91,11 +91,13 @@ public class DomainHistory extends HistoryEntry { @ElementCollection @JoinTable( name = "DomainHistoryHost", - indexes = - @Index( - columnList = - "domain_history_history_revision_id,domain_history_domain_repo_id,host_repo_id", - unique = true)) + indexes = { + @Index(columnList = "domain_history_domain_repo_id"), + @Index( + columnList = + "domain_history_history_revision_id,domain_history_domain_repo_id,host_repo_id", + unique = true) + }) @Column(name = "host_repo_id") Set> nsHosts; diff --git a/core/src/main/java/google/registry/model/poll/PollMessage.java b/core/src/main/java/google/registry/model/poll/PollMessage.java index 3902896e3..72cc4dc2b 100644 --- a/core/src/main/java/google/registry/model/poll/PollMessage.java +++ b/core/src/main/java/google/registry/model/poll/PollMessage.java @@ -86,7 +86,12 @@ import org.joda.time.DateTime; @ExternalMessagingName("message") @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name = "type") -@Table(indexes = {@Index(columnList = "registrar_id"), @Index(columnList = "eventTime")}) +@Table( + indexes = { + @Index(columnList = "domainRepoId"), + @Index(columnList = "registrar_id"), + @Index(columnList = "eventTime") + }) public abstract class PollMessage extends ImmutableObject implements Buildable, TransferServerApproveEntity, UnsafeSerializable { diff --git a/db/src/main/resources/sql/flyway/V161__add_domain_repo_id_indexes_to_more_tables.sql b/db/src/main/resources/sql/flyway/V161__add_domain_repo_id_indexes_to_more_tables.sql new file mode 100644 index 000000000..b9751d234 --- /dev/null +++ b/db/src/main/resources/sql/flyway/V161__add_domain_repo_id_indexes_to_more_tables.sql @@ -0,0 +1,16 @@ +-- Copyright 2024 The Nomulus Authors. All Rights Reserved. +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. + +CREATE INDEX CONCURRENTLY IDX69qun5kxt3eux5igrxrqcycv0 ON "DomainHistoryHost" (domain_history_domain_repo_id); +CREATE INDEX CONCURRENTLY IDXf2q9dqj899h1q8lah5y719nxd ON "PollMessage" (domain_repo_id); diff --git a/db/src/main/resources/sql/schema/db-schema.sql.generated b/db/src/main/resources/sql/schema/db-schema.sql.generated index e44abda33..6fd4bdd99 100644 --- a/db/src/main/resources/sql/schema/db-schema.sql.generated +++ b/db/src/main/resources/sql/schema/db-schema.sql.generated @@ -848,6 +848,7 @@ create index IDXrh4xmrot9bd63o382ow9ltfig on "DomainHistory" (creation_time); create index IDXaro1omfuaxjwmotk3vo00trwm on "DomainHistory" (history_registrar_id); create index IDXsu1nam10cjes9keobapn5jvxj on "DomainHistory" (history_type); create index IDX6w3qbtgce93cal2orjg1tw7b7 on "DomainHistory" (history_modification_time); +create index IDX69qun5kxt3eux5igrxrqcycv0 on "DomainHistoryHost" (domain_history_domain_repo_id); alter table if exists "DomainHistoryHost" add constraint UKt2e7ae3t8gcsxd13wjx2ka7ij unique (domain_history_history_revision_id, domain_history_domain_repo_id, host_repo_id); @@ -869,6 +870,7 @@ create index IDXkkwbwcwvrdkkqothkiye4jiff on "HostHistory" (host_name); create index IDXknk8gmj7s47q56cwpa6rmpt5l on "HostHistory" (history_type); create index IDX67qwkjtlq5q8dv6egtrtnhqi7 on "HostHistory" (history_modification_time); create index IDXlg6a5tp70nch9cp0gc11brc5o on "PackagePromotion" (token); +create index IDXf2q9dqj899h1q8lah5y719nxd on "PollMessage" (domain_repo_id); create index IDXe7wu46c7wpvfmfnj4565abibp on "PollMessage" (registrar_id); create index IDXaydgox62uno9qx8cjlj5lauye on "PollMessage" (event_time); create index premiumlist_name_idx on "PremiumList" (name);