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.
This commit is contained in:
Weimin Yu 2022-02-03 15:57:15 -05:00 committed by GitHub
parent 4d08fadc11
commit cdcdde2c96
7 changed files with 600 additions and 573 deletions

View file

@ -34,6 +34,9 @@ import javax.persistence.AccessType;
@ReportedOn @ReportedOn
@Entity @Entity
@javax.persistence.Entity(name = "Host") @javax.persistence.Entity(name = "Host")
@javax.persistence.Table(
name = "Host",
indexes = {@javax.persistence.Index(columnList = "hostName")})
@ExternalMessagingName("host") @ExternalMessagingName("host")
@WithStringVKey @WithStringVKey
@Access(AccessType.FIELD) // otherwise it'll use the default if the repoId (property) @Access(AccessType.FIELD) // otherwise it'll use the default if the repoId (property)

File diff suppressed because it is too large Load diff

View file

@ -261,19 +261,11 @@ td.section {
</tr> </tr>
<tr> <tr>
<td class="property_name">generated on</td> <td class="property_name">generated on</td>
<<<<<<< HEAD <td class="property_value">2022-02-03 18:23:54.985476</td>
<td class="property_value">2021-11-23 20:43:39.672931</td>
</tr> </tr>
<tr> <tr>
<td class="property_name">last flyway file</td> <td class="property_name">last flyway file</td>
<td id="lastFlywayFile" class="property_value">V104__add_transfer_response_host_id_to_poll_message.sql</td> <td id="lastFlywayFile" class="property_value">V105__add_index_on_host_name_in_host_table.sql</td>
=======
<td class="property_value">2021-11-17 21:23:10.198048</td>
</tr>
<tr>
<td class="property_name">last flyway file</td>
<td id="lastFlywayFile" class="property_value">V103__add_transfer_response_host_id_to_poll_message.sql</td>
>>>>>>> 19aa29939 (Fix missing hostPendingActionNotificationResponses in PollMessage.OneTime)
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -292,11 +284,7 @@ td.section {
generated on generated on
</text> </text>
<text text-anchor="start" x="4755.52" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="4755.52" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">
<<<<<<< HEAD 2022-02-03 18:23:54.985476
2021-11-23 20:43:39.672931
=======
2021-11-17 21:23:10.198048
>>>>>>> 19aa29939 (Fix missing hostPendingActionNotificationResponses in PollMessage.OneTime)
</text> </text>
<polygon fill="none" stroke="#888888" points="4668.02,-4 4668.02,-44 4933.02,-44 4933.02,-4 4668.02,-4" /> <!-- allocationtoken_a08ccbef --> <polygon fill="none" stroke="#888888" points="4668.02,-4 4668.02,-44 4933.02,-44 4933.02,-4 4668.02,-4" /> <!-- allocationtoken_a08ccbef -->
<g id="node1" class="node"> <g id="node1" class="node">
@ -11179,6 +11167,18 @@ td.section {
<tr> <tr>
<td colspan="3"></td> <td colspan="3"></td>
</tr> </tr>
<tr>
<td colspan="2" class="name">idxkpkh68n6dy5v51047yr6b0e9l</td>
<td class="description right">[non-unique index]</td>
</tr>
<tr>
<td class="spacer"></td>
<td class="minwidth">host_name</td>
<td class="minwidth">ascending</td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
<tr> <tr>
<td colspan="2" class="name">Host_pkey</td> <td colspan="2" class="name">Host_pkey</td>
<td class="description right">[unique index]</td> <td class="description right">[unique index]</td>

View file

@ -102,3 +102,4 @@ V101__domain_add_dns_refresh_request_time.sql
V102__add_indexes_to_domain_history_sub_tables.sql V102__add_indexes_to_domain_history_sub_tables.sql
V103__creation_time_not_null.sql V103__creation_time_not_null.sql
V104__add_transfer_response_host_id_to_poll_message.sql V104__add_transfer_response_host_id_to_poll_message.sql
V105__add_index_on_host_name_in_host_table.sql

View file

@ -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);

View file

@ -804,6 +804,7 @@ create index IDX6w3qbtgce93cal2orjg1tw7b7 on "DomainHistory" (history_modificati
add constraint UKat9erbh52e4lg3jw6ai9wkjj9 unique (domain_repo_id, host_repo_id); add constraint UKat9erbh52e4lg3jw6ai9wkjj9 unique (domain_repo_id, host_repo_id);
create index IDXj1mtx98ndgbtb1bkekahms18w on "GracePeriod" (domain_repo_id); create index IDXj1mtx98ndgbtb1bkekahms18w on "GracePeriod" (domain_repo_id);
create index IDXd01j17vrpjxaerxdmn8bwxs7s on "GracePeriodHistory" (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 IDXfg2nnjlujxo6cb9fha971bq2n on "HostHistory" (creation_time);
create index IDX1iy7njgb7wjmj9piml4l2g0qi on "HostHistory" (history_registrar_id); create index IDX1iy7njgb7wjmj9piml4l2g0qi on "HostHistory" (history_registrar_id);
create index IDXkkwbwcwvrdkkqothkiye4jiff on "HostHistory" (host_name); create index IDXkkwbwcwvrdkkqothkiye4jiff on "HostHistory" (host_name);

View file

@ -1728,6 +1728,13 @@ CREATE INDEX idxkjt9yaq92876dstimd93hwckh ON public."Domain" USING btree (curren
CREATE INDEX idxknk8gmj7s47q56cwpa6rmpt5l ON public."HostHistory" USING btree (history_type); 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: - -- Name: idxlrq7v63pc21uoh3auq6eybyhl; Type: INDEX; Schema: public; Owner: -
-- --