From e2bd72a74ebb269877126052e9300393e19828b7 Mon Sep 17 00:00:00 2001 From: Weimin Yu Date: Thu, 3 Feb 2022 15:57:15 -0500 Subject: [PATCH] Add an index on Host.host_name column (#1510) * Add an index on Host.host_name column This field is queried during host creation and needs an index to speed up the query. Since Hibernate does not explicitly refer to indexes, we can change the code and schema in one PR. --- .../registry/model/host/HostResource.java | 3 + .../sql/er_diagram/brief_er_diagram.html | 1116 ++++++++--------- .../sql/er_diagram/full_er_diagram.html | 30 +- db/src/main/resources/sql/flyway.txt | 1 + ...__add_index_on_host_name_in_host_table.sql | 15 + .../sql/schema/db-schema.sql.generated | 1 + .../resources/sql/schema/nomulus.golden.sql | 7 + 7 files changed, 600 insertions(+), 573 deletions(-) create mode 100644 db/src/main/resources/sql/flyway/V105__add_index_on_host_name_in_host_table.sql diff --git a/core/src/main/java/google/registry/model/host/HostResource.java b/core/src/main/java/google/registry/model/host/HostResource.java index 05a99e30d..27cc43e6f 100644 --- a/core/src/main/java/google/registry/model/host/HostResource.java +++ b/core/src/main/java/google/registry/model/host/HostResource.java @@ -34,6 +34,9 @@ import javax.persistence.AccessType; @ReportedOn @Entity @javax.persistence.Entity(name = "Host") +@javax.persistence.Table( + name = "Host", + indexes = {@javax.persistence.Index(columnList = "hostName")}) @ExternalMessagingName("host") @WithStringVKey @Access(AccessType.FIELD) // otherwise it'll use the default if the repoId (property) diff --git a/db/src/main/resources/sql/er_diagram/brief_er_diagram.html b/db/src/main/resources/sql/er_diagram/brief_er_diagram.html index a6eeff2f0..edbaa2b1a 100644 --- a/db/src/main/resources/sql/er_diagram/brief_er_diagram.html +++ b/db/src/main/resources/sql/er_diagram/brief_er_diagram.html @@ -261,19 +261,11 @@ td.section { generated on -<<<<<<< HEAD - 2021-11-23 20:43:41.968049 + 2022-02-03 18:23:57.232542 last flyway file - V104__add_transfer_response_host_id_to_poll_message.sql -======= - 2021-11-17 21:23:12.62481 - - - last flyway file - V103__add_transfer_response_host_id_to_poll_message.sql ->>>>>>> 19aa29939 (Fix missing hostPendingActionNotificationResponses in PollMessage.OneTime) + V105__add_index_on_host_name_in_host_table.sql @@ -282,24 +274,19 @@ td.section { SchemaCrawler_Diagram - + generated by - + SchemaCrawler 16.10.1 - + generated on -<<<<<<< HEAD - 2021-11-23 20:43:41.968049 -======= - - 2021-11-17 21:23:12.62481 ->>>>>>> 19aa29939 (Fix missing hostPendingActionNotificationResponses in PollMessage.OneTime) + 2022-02-03 18:23:57.232542 - + allocationtoken_a08ccbef @@ -628,147 +615,147 @@ td.section { registrar_6e1503e3 - - + + public.Registrar - - + + [table] - + registrar_id - + - + text not null - + iana_identifier - + - + int8 - + registrar_name - + - + text not null - + billingevent_a57d1815:w->registrar_6e1503e3:e - + - - - - + + + + fk_billing_event_registrar_id billingcancellation_6eedf614 - - + + public.BillingCancellation - - + + [table] - + billing_cancellation_id - + - + int8 not null - + registrar_id - + - + text not null - + domain_history_revision_id - + - + int8 not null - + domain_repo_id - + - + text not null - + event_time - + - + timestamptz not null - + billing_time - + - + timestamptz - + billing_event_id - + - + int8 - + billing_recurrence_id - + - + int8 - + billingcancellation_6eedf614:w->billingevent_a57d1815:e - - - + + + - + fk_billing_cancellation_billing_event_id billingcancellation_6eedf614:w->billingrecurrence_5fa2cb01:e - - - + + + @@ -779,221 +766,221 @@ td.section { billingcancellation_6eedf614:w->domainhistory_a54cc226:e - - - - + + + + - - - + + + fk_billing_cancellation_domain_history billingcancellation_6eedf614:w->domainhistory_a54cc226:e - - - + + + - + fk_billing_cancellation_domain_history billingcancellation_6eedf614:w->registrar_6e1503e3:e - - - - - - - - + + + + + + + + fk_billing_cancellation_registrar_id domain_6c51cffa - - + + public.Domain - - + + [table] - + repo_id - + - + text not null - + creation_registrar_id - + - + text not null - + creation_time - + - + timestamptz not null - + current_sponsor_registrar_id - + - + text not null - + deletion_time - + - + timestamptz - + last_epp_update_registrar_id - + - + text - + domain_name - + - + text - + tld - + - + text - + admin_contact - + - + text - + billing_contact - + - + text - + registrant_contact - + - + text - + tech_contact - + - + text - + transfer_billing_cancellation_id - + - + int8 - + transfer_billing_event_id - + - + int8 - + transfer_billing_recurrence_id - + - + int8 - + transfer_gaining_registrar_id - + - + text - + transfer_losing_registrar_id - + - + text - + billing_recurrence_id - + - + int8 - + autorenew_end_time - + - + timestamptz - + dns_refresh_request_time - + - + timestamptz - + domain_6c51cffa:w->billingevent_a57d1815:e - - - - + + + + @@ -1003,22 +990,22 @@ td.section { domain_6c51cffa:w->billingcancellation_6eedf614:e - - - - - - - - + + + + + + + + fk_domain_transfer_billing_cancellation_id domain_6c51cffa:w->billingrecurrence_5fa2cb01:e - - - + + + @@ -1029,9 +1016,9 @@ td.section { domain_6c51cffa:w->billingrecurrence_5fa2cb01:e - - - + + + @@ -1042,346 +1029,346 @@ td.section { contact_8de8cb16 - - + + public.Contact - - + + [table] - + repo_id - + - + text not null - + creation_registrar_id - + - + text not null - + creation_time - + - + timestamptz not null - + current_sponsor_registrar_id - + - + text not null - + deletion_time - + - + timestamptz - + last_epp_update_registrar_id - + - + text - + contact_id - + - + text - + search_name - + - + text - + transfer_gaining_registrar_id - + - + text - + transfer_losing_registrar_id - + - + text - + domain_6c51cffa:w->contact_8de8cb16:e - - - - - - - - + + + + + + + + fk_domain_admin_contact domain_6c51cffa:w->contact_8de8cb16:e - - - - - - - - + + + + + + + + fk_domain_billing_contact domain_6c51cffa:w->contact_8de8cb16:e - - - - - - - - + + + + + + + + fk_domain_registrant_contact domain_6c51cffa:w->contact_8de8cb16:e - - - - - - - - + + + + + + + + fk_domain_tech_contact domain_6c51cffa:w->registrar_6e1503e3:e - - - - - - - - + + + + + + + + fk2jc69qyg2tv9hhnmif6oa1cx1 domain_6c51cffa:w->registrar_6e1503e3:e - - - - - - - - + + + + + + + + fk2u3srsfbei272093m3b3xwj23 domain_6c51cffa:w->registrar_6e1503e3:e - - - - - - - - + + + + + + + + fkjc0r9r5y1lfbt4gpbqw4wsuvq domain_6c51cffa:w->registrar_6e1503e3:e - - - - - - - - + + + + + + + + fk_domain_transfer_gaining_registrar_id domain_6c51cffa:w->registrar_6e1503e3:e - - - - - - - - + + + + + + + + fk_domain_transfer_losing_registrar_id tld_f1fa57e2 - - + + public.Tld - - + + [table] - + tld_name - + - + text not null - + domain_6c51cffa:w->tld_f1fa57e2:e - - - - - - - - + + + + + + + + fk_domain_tld graceperiod_cd3b2e8f - - + + public.GracePeriod - - + + [table] - + grace_period_id - + - + int8 not null - + billing_event_id - + - + int8 - + billing_recurrence_id - + - + int8 - + registrar_id - + - + text not null - + domain_repo_id - + - + text not null - + graceperiod_cd3b2e8f:w->billingevent_a57d1815:e - - - - - - - - + + + + + + + + fk_grace_period_billing_event_id graceperiod_cd3b2e8f:w->domain_6c51cffa:e - - - - - - - - + + + + + + + + fk_grace_period_domain_repo_id graceperiod_cd3b2e8f:w->billingrecurrence_5fa2cb01:e - - - - - - - - + + + + + + + + fk_grace_period_billing_recurrence_id graceperiod_cd3b2e8f:w->registrar_6e1503e3:e - - - - - - - + + + + + + + fk_grace_period_registrar_id @@ -1414,13 +1401,13 @@ td.section { billingrecurrence_5fa2cb01:w->registrar_6e1503e3:e - - - - - - - + + + + + + + fk_billing_recurrence_registrar_id @@ -1493,66 +1480,66 @@ td.section { contact_8de8cb16:w->registrar_6e1503e3:e - - - - - - - - + + + + + + + + fk1sfyj7o7954prbn1exk7lpnoe contact_8de8cb16:w->registrar_6e1503e3:e - - - - - - - - + + + + + + + + fk93c185fx7chn68uv7nl6uv2s0 contact_8de8cb16:w->registrar_6e1503e3:e - - - - - - - - + + + + + + + + fkmb7tdiv85863134w1wogtxrb2 contact_8de8cb16:w->registrar_6e1503e3:e - - - - - - - - + + + + + + + + fk_contact_transfer_gaining_registrar_id contact_8de8cb16:w->registrar_6e1503e3:e - - - - - - - - + + + + + + + + fk_contact_transfer_losing_registrar_id @@ -1618,27 +1605,27 @@ td.section { contacthistory_d2964f8a:w->contact_8de8cb16:e - - - - - - - - + + + + + + + + fk_contact_history_contact_repo_id contacthistory_d2964f8a:w->registrar_6e1503e3:e - - - - - - - - + + + + + + + + fk_contact_history_registrar_id @@ -1744,27 +1731,27 @@ td.section { pollmessage_614a523e:w->domain_6c51cffa:e - + - - - - - + + + + + fk_poll_message_domain_repo_id pollmessage_614a523e:w->contact_8de8cb16:e - + - - - - - - + + + + + + fk_poll_message_contact_repo_id @@ -1796,9 +1783,9 @@ td.section { pollmessage_614a523e:w->domainhistory_a54cc226:e - - - + + + @@ -1822,24 +1809,32 @@ td.section { host_f21b78de - - + + public.Host - - + + [table] - + repo_id + + + + text not null + + + creation_registrar_id + - text not null + text - creation_registrar_id + current_sponsor_registrar_id @@ -1847,7 +1842,7 @@ td.section { text - current_sponsor_registrar_id + last_epp_update_registrar_id @@ -1855,7 +1850,7 @@ td.section { text - last_epp_update_registrar_id + host_name @@ -1870,18 +1865,18 @@ td.section { text - + pollmessage_614a523e:w->host_f21b78de:e - + - - - - - + + + + + fk_poll_message_host_repo_id @@ -1981,39 +1976,39 @@ td.section { pollmessage_614a523e:w->registrar_6e1503e3:e - + - - - - + + + + fk_poll_message_registrar_id pollmessage_614a523e:w->registrar_6e1503e3:e - - - - - - - - + + + + + + + + fk_poll_message_transfer_response_gaining_registrar_id pollmessage_614a523e:w->registrar_6e1503e3:e - - - - - - - + + + + + + + fk_poll_message_transfer_response_losing_registrar_id @@ -2120,40 +2115,40 @@ td.section { delegationsignerdata_e542a872:w->domain_6c51cffa:e - + - - - - + + + + fktr24j9v14ph2mfuw2gsmt12kq domainhistory_a54cc226:w->domain_6c51cffa:e - + - - - - + + + + fk_domain_history_domain_repo_id domainhistory_a54cc226:w->registrar_6e1503e3:e - - - - - - - - + + + + + + + + fk_domain_history_registrar_id @@ -2187,79 +2182,79 @@ td.section { domainhost_1ea127c2:w->domain_6c51cffa:e - + - - - - + + + + fkfmi7bdink53swivs390m2btxg domainhost_1ea127c2:w->host_f21b78de:e - - - - - - - - + + + + + + + + fk_domainhost_host_valid host_f21b78de:w->domain_6c51cffa:e - - - - - - - - + + + + + + + + fk_host_superordinate_domain host_f21b78de:w->registrar_6e1503e3:e - - - - - - - - + + + + + + + + fk_host_creation_registrar_id host_f21b78de:w->registrar_6e1503e3:e - - - - - - - - + + + + + + + + fk_host_current_sponsor_registrar_id host_f21b78de:w->registrar_6e1503e3:e - - - - - - - - + + + + + + + + fk_host_last_epp_update_registrar_id @@ -2464,14 +2459,14 @@ td.section { domaintransactionrecord_6e77ff61:w->tld_f1fa57e2:e - - - - - - - - + + + + + + + + fk_domain_transaction_record_tld @@ -2539,27 +2534,27 @@ td.section { hosthistory_56210c2:w->host_f21b78de:e - - - - - - - - + + + + + + + + fk_hosthistory_host hosthistory_56210c2:w->registrar_6e1503e3:e - - - - - - - - + + + + + + + + fk_history_registrar_id @@ -2739,13 +2734,13 @@ td.section { registrarpoc_ab47054d:w->registrar_6e1503e3:e - + - - - - + + + + fk_registrar_poc_registrar_id @@ -5262,6 +5257,11 @@ td.section { last_epp_update_registrar_id text +
+ + host_name + text +
superordinate_domain diff --git a/db/src/main/resources/sql/er_diagram/full_er_diagram.html b/db/src/main/resources/sql/er_diagram/full_er_diagram.html index f12faddb3..6b9481b42 100644 --- a/db/src/main/resources/sql/er_diagram/full_er_diagram.html +++ b/db/src/main/resources/sql/er_diagram/full_er_diagram.html @@ -261,19 +261,11 @@ td.section {
generated on -<<<<<<< HEAD - 2021-11-23 20:43:39.672931 + 2022-02-03 18:23:54.985476
last flyway file - V104__add_transfer_response_host_id_to_poll_message.sql -======= - 2021-11-17 21:23:10.198048 -
-
- last flyway file - V103__add_transfer_response_host_id_to_poll_message.sql ->>>>>>> 19aa29939 (Fix missing hostPendingActionNotificationResponses in PollMessage.OneTime) + V105__add_index_on_host_name_in_host_table.sql
@@ -292,11 +284,7 @@ td.section { generated on -<<<<<<< HEAD - 2021-11-23 20:43:39.672931 -======= - 2021-11-17 21:23:10.198048 ->>>>>>> 19aa29939 (Fix missing hostPendingActionNotificationResponses in PollMessage.OneTime) + 2022-02-03 18:23:54.985476 @@ -11179,6 +11167,18 @@ td.section {
+
+ idxkpkh68n6dy5v51047yr6b0e9l + [non-unique index] +
+
+ + host_name + ascending +
+
+ +
Host_pkey [unique index] diff --git a/db/src/main/resources/sql/flyway.txt b/db/src/main/resources/sql/flyway.txt index f64e6e8a1..a96c3576a 100644 --- a/db/src/main/resources/sql/flyway.txt +++ b/db/src/main/resources/sql/flyway.txt @@ -102,3 +102,4 @@ V101__domain_add_dns_refresh_request_time.sql V102__add_indexes_to_domain_history_sub_tables.sql V103__creation_time_not_null.sql V104__add_transfer_response_host_id_to_poll_message.sql +V105__add_index_on_host_name_in_host_table.sql diff --git a/db/src/main/resources/sql/flyway/V105__add_index_on_host_name_in_host_table.sql b/db/src/main/resources/sql/flyway/V105__add_index_on_host_name_in_host_table.sql new file mode 100644 index 000000000..e4b96d2f4 --- /dev/null +++ b/db/src/main/resources/sql/flyway/V105__add_index_on_host_name_in_host_table.sql @@ -0,0 +1,15 @@ +-- Copyright 2022 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 IDXkpkh68n6dy5v51047yr6b0e9l ON "Host" (host_name); 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 719851f22..069c52aa8 100644 --- a/db/src/main/resources/sql/schema/db-schema.sql.generated +++ b/db/src/main/resources/sql/schema/db-schema.sql.generated @@ -804,6 +804,7 @@ create index IDX6w3qbtgce93cal2orjg1tw7b7 on "DomainHistory" (history_modificati add constraint UKat9erbh52e4lg3jw6ai9wkjj9 unique (domain_repo_id, host_repo_id); create index IDXj1mtx98ndgbtb1bkekahms18w on "GracePeriod" (domain_repo_id); create index IDXd01j17vrpjxaerxdmn8bwxs7s on "GracePeriodHistory" (domain_repo_id); +create index IDXkpkh68n6dy5v51047yr6b0e9l on "Host" (host_name); create index IDXfg2nnjlujxo6cb9fha971bq2n on "HostHistory" (creation_time); create index IDX1iy7njgb7wjmj9piml4l2g0qi on "HostHistory" (history_registrar_id); create index IDXkkwbwcwvrdkkqothkiye4jiff on "HostHistory" (host_name); diff --git a/db/src/main/resources/sql/schema/nomulus.golden.sql b/db/src/main/resources/sql/schema/nomulus.golden.sql index d073c1ec6..c34c29014 100644 --- a/db/src/main/resources/sql/schema/nomulus.golden.sql +++ b/db/src/main/resources/sql/schema/nomulus.golden.sql @@ -1728,6 +1728,13 @@ CREATE INDEX idxkjt9yaq92876dstimd93hwckh ON public."Domain" USING btree (curren CREATE INDEX idxknk8gmj7s47q56cwpa6rmpt5l ON public."HostHistory" USING btree (history_type); +-- +-- Name: idxkpkh68n6dy5v51047yr6b0e9l; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idxkpkh68n6dy5v51047yr6b0e9l ON public."Host" USING btree (host_name); + + -- -- Name: idxlrq7v63pc21uoh3auq6eybyhl; Type: INDEX; Schema: public; Owner: - --