From 97d0b7680fc35d9ed91cfeaf9c0619c231e9f6f9 Mon Sep 17 00:00:00 2001 From: gbrodman Date: Mon, 29 Sep 2025 18:16:24 -0400 Subject: [PATCH] Add hash indexes for common use cases (#2834) I went through all the SQL statements generated by some sample DomainCreateFlow and DomainDeleteFlow cases to find situations where we were either SELECTing from, or UPDATEing, tables with a direct "field = value" format. These are the situations that I found where we can add hash indexes. This does two things: 1. Makes these queries slight faster, since these are usually queries on columns that are either unique or very close to unique, and O(1) is faster than O(log(n)) 2. Spreads around the optimistic predicate locks on the previously-used btree indexes. Many of our serialization errors came from the fact that we were autogenerating incrementing ID values for various tables, meaning that SELECTs, INSERTs, and UPDATEs would all try to take predicate locks out on the same page of the btree index. Using a hash index means that the page locks will be spread out to various index pages, rather than conflicting with each other. Running load tests on alpha I see significant improvements in speed and error rates. Speed is hard to quantify due to the nature of the way the load tests distribute tasks among the queues but it could be more than 50% improvement, and serialization errors in the logs drop by more than 90%. --- .../sql/er_diagram/brief_er_diagram.html | 6 +- .../sql/er_diagram/full_er_diagram.html | 210 +++++++++++++++++- db/src/main/resources/sql/flyway.txt | 12 + .../V198__billing_cancellation_hash.sql | 16 ++ .../sql/flyway/V199__billing_event_hash.sql | 16 ++ .../flyway/V200__billing_recurrence_hash.sql | 16 ++ .../sql/flyway/V201__domain_hash.sql | 17 ++ .../V202__delegation_signer_data_hash.sql | 16 ++ .../sql/flyway/V203__domain_history_hash.sql | 17 ++ .../sql/flyway/V204__domain_host_hash.sql | 16 ++ .../V205__domain_transaction_record_hash.sql | 17 ++ .../sql/flyway/V206__grace_period_hash.sql | 17 ++ .../V207__grace_period_history_hash.sql | 16 ++ .../resources/sql/flyway/V208__host_hash.sql | 17 ++ .../sql/flyway/V209__poll_message_hash.sql | 16 ++ .../resources/sql/schema/nomulus.golden.sql | 119 ++++++++++ 16 files changed, 538 insertions(+), 6 deletions(-) create mode 100644 db/src/main/resources/sql/flyway/V198__billing_cancellation_hash.sql create mode 100644 db/src/main/resources/sql/flyway/V199__billing_event_hash.sql create mode 100644 db/src/main/resources/sql/flyway/V200__billing_recurrence_hash.sql create mode 100644 db/src/main/resources/sql/flyway/V201__domain_hash.sql create mode 100644 db/src/main/resources/sql/flyway/V202__delegation_signer_data_hash.sql create mode 100644 db/src/main/resources/sql/flyway/V203__domain_history_hash.sql create mode 100644 db/src/main/resources/sql/flyway/V204__domain_host_hash.sql create mode 100644 db/src/main/resources/sql/flyway/V205__domain_transaction_record_hash.sql create mode 100644 db/src/main/resources/sql/flyway/V206__grace_period_hash.sql create mode 100644 db/src/main/resources/sql/flyway/V207__grace_period_history_hash.sql create mode 100644 db/src/main/resources/sql/flyway/V208__host_hash.sql create mode 100644 db/src/main/resources/sql/flyway/V209__poll_message_hash.sql 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 16ebcbcf2..42b34723b 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,11 +261,11 @@ td.section { generated on - 2025-09-05 16:11:29 + 2025-09-29 21:19:42 last flyway file - V197__poc_rlock_drop_not_null.sql + V209__poll_message_hash.sql @@ -273,7 +273,7 @@ td.section {

 

- SchemaCrawler_Diagram generated by SchemaCrawler 16.27.1 generated on 2025-09-05 16:11:29 + SchemaCrawler_Diagram generated by SchemaCrawler 16.27.1 generated on 2025-09-29 21:19:42 allocationtoken_a08ccbef public."AllocationToken" [table] token text not null domain_name text redemption_domain_repo_id text token_type text 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 c540f57cb..485b58dd6 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,11 +261,11 @@ td.section {
generated on - 2025-09-05 16:11:26 + 2025-09-29 21:19:38
last flyway file - V197__poc_rlock_drop_not_null.sql + V209__poll_message_hash.sql
@@ -273,7 +273,7 @@ td.section {

 

- SchemaCrawler_Diagram generated by SchemaCrawler 16.27.1 generated on 2025-09-05 16:11:26 + SchemaCrawler_Diagram generated by SchemaCrawler 16.27.1 generated on 2025-09-29 21:19:38 allocationtoken_a08ccbef public."AllocationToken" [table] token text not null update_timestamp timestamptz allowed_registrar_ids _text allowed_tlds _text creation_time timestamptz not null discount_fraction float8(17, 17) not null discount_premiums bool not null discount_years int4 not null domain_name text redemption_domain_repo_id text token_status_transitions hstore token_type text redemption_domain_history_id int8 renewal_price_behavior text not null registration_behavior text not null allowed_epp_actions _text renewal_price_amount numeric(19, 2) renewal_price_currency text discount_price_amount numeric(19, 2) discount_price_currency text @@ -1137,6 +1137,18 @@ td.section {
+
+ billingcancellation_billing_cancellation_id_hash + [non-unique hashed index] +
+
+ + billing_cancellation_id + unknown +
+
+ +
idx4ytbe5f3b39trsd4okx5ijhs4 [non-unique index] @@ -1428,6 +1440,18 @@ td.section {
+
+ billingevent_billing_event_id_hash + [non-unique hashed index] +
+
+ + billing_event_id + unknown +
+
+ +
idx6ebt3nwk5ocvnremnhnlkl6ff [non-unique index] @@ -1748,6 +1772,18 @@ td.section {
+
+ billingrecurrence_billing_recurrence_id_hash + [non-unique hashed index] +
+
+ + billing_recurrence_id + unknown +
+
+ +
idxoqttafcywwdn41um6kwlt0n8b [non-unique index] @@ -3803,6 +3839,18 @@ td.section {
+
+ delegationsignerdata_domain_repo_id_hash + [non-unique hashed index] +
+
+ + domain_repo_id + unknown +
+
+ +
idxhlqqd5uy98cjyos72d81x9j95 [non-unique index] @@ -4599,6 +4647,18 @@ td.section {
+
+ domain_domain_name_hash + [non-unique hashed index] +
+
+ + domain_name + unknown +
+
+ +
idx1rcgkdd777bpvj0r94sltwd5y [non-unique index] @@ -4647,6 +4707,18 @@ td.section {
+
+ domain_domain_repo_id_hash + [non-unique hashed index] +
+
+ + repo_id + unknown +
+
+ +
idxr22ciyccwi9rrqmt1ro0s59qf [non-unique index] @@ -5256,6 +5328,30 @@ td.section {
+
+ domainhistory_history_revision_id_hash + [non-unique hashed index] +
+
+ + history_revision_id + unknown +
+
+ +
+
+ domainhistory_domain_repo_id_hash + [non-unique hashed index] +
+
+ + domain_repo_id + unknown +
+
+ +
idxaro1omfuaxjwmotk3vo00trwm [non-unique index] @@ -5461,6 +5557,18 @@ td.section {
+
+ domainhost_domain_repo_id_hash + [non-unique hashed index] +
+
+ + domain_repo_id + unknown +
+
+ +
idxjw3rwtfrexyq53x9vu7qghrdt [non-unique index] @@ -5597,6 +5705,30 @@ td.section {
+
+ domaintransactionrecord_id_hash + [non-unique hashed index] +
+
+ + id + unknown +
+
+ +
+
+ domaintransactionrecord_domain_history_revision_id_hash + [non-unique hashed index] +
+
+ + history_revision_id + unknown +
+
+ +
domain_history_to_transaction_record_idx [non-unique index] @@ -5842,6 +5974,30 @@ td.section {
+
+ graceperiod_grace_period_id_hash + [non-unique hashed index] +
+
+ + grace_period_id + unknown +
+
+ +
+
+ graceperiod_domain_repo_id_hash + [non-unique hashed index] +
+
+ + domain_repo_id + unknown +
+
+ +
idxj1mtx98ndgbtb1bkekahms18w [non-unique index] @@ -5943,6 +6099,18 @@ td.section {
+
+ graceperiodhistory_grace_period_history_revision_id_hash + [non-unique hashed index] +
+
+ + grace_period_history_revision_id + unknown +
+
+ +
idxd01j17vrpjxaerxdmn8bwxs7s [non-unique index] @@ -6198,6 +6366,18 @@ td.section {
+
+ host_host_name_hash + [non-unique hashed index] +
+
+ + host_name + unknown +
+
+ +
idxkpkh68n6dy5v51047yr6b0e9l [non-unique index] @@ -6222,6 +6402,18 @@ td.section {
+
+ host_repo_id_hash + [non-unique hashed index] +
+
+ + repo_id + unknown +
+
+ +
idxorp4yv9ult4ds6kgxo5fs5gnw [non-unique index] @@ -7099,6 +7291,18 @@ td.section {
+
+ pollmessage_poll_message_id_hash + [non-unique hashed index] +
+
+ + poll_message_id + unknown +
+
+ +
idxf2q9dqj899h1q8lah5y719nxd [non-unique index] diff --git a/db/src/main/resources/sql/flyway.txt b/db/src/main/resources/sql/flyway.txt index 6f6d38884..12c489e49 100644 --- a/db/src/main/resources/sql/flyway.txt +++ b/db/src/main/resources/sql/flyway.txt @@ -195,3 +195,15 @@ V194__password_reset_request_registrar.sql V195__registrar_poc_id.sql V196__tld_expiry_access_period_enabled.sql V197__poc_rlock_drop_not_null.sql +V198__billing_cancellation_hash.sql +V199__billing_event_hash.sql +V200__billing_recurrence_hash.sql +V201__domain_hash.sql +V202__delegation_signer_data_hash.sql +V203__domain_history_hash.sql +V204__domain_host_hash.sql +V205__domain_transaction_record_hash.sql +V206__grace_period_hash.sql +V207__grace_period_history_hash.sql +V208__host_hash.sql +V209__poll_message_hash.sql diff --git a/db/src/main/resources/sql/flyway/V198__billing_cancellation_hash.sql b/db/src/main/resources/sql/flyway/V198__billing_cancellation_hash.sql new file mode 100644 index 000000000..975ce199e --- /dev/null +++ b/db/src/main/resources/sql/flyway/V198__billing_cancellation_hash.sql @@ -0,0 +1,16 @@ +-- Copyright 2025 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. + +-- Add hash indexes on columns that are commonly queried with a direct equals +CREATE INDEX CONCURRENTLY IF NOT EXISTS billingcancellation_billing_cancellation_id_hash ON "BillingCancellation" USING hash (billing_cancellation_id); diff --git a/db/src/main/resources/sql/flyway/V199__billing_event_hash.sql b/db/src/main/resources/sql/flyway/V199__billing_event_hash.sql new file mode 100644 index 000000000..b833b532a --- /dev/null +++ b/db/src/main/resources/sql/flyway/V199__billing_event_hash.sql @@ -0,0 +1,16 @@ +-- Copyright 2025 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. + +-- Add hash indexes on columns that are commonly queried with a direct equals +CREATE INDEX CONCURRENTLY IF NOT EXISTS billingevent_billing_event_id_hash ON "BillingEvent" USING hash (billing_event_id); diff --git a/db/src/main/resources/sql/flyway/V200__billing_recurrence_hash.sql b/db/src/main/resources/sql/flyway/V200__billing_recurrence_hash.sql new file mode 100644 index 000000000..cbfdf8a76 --- /dev/null +++ b/db/src/main/resources/sql/flyway/V200__billing_recurrence_hash.sql @@ -0,0 +1,16 @@ +-- Copyright 2025 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. + +-- Add hash indexes on columns that are commonly queried with a direct equals +CREATE INDEX CONCURRENTLY IF NOT EXISTS billingrecurrence_billing_recurrence_id_hash ON "BillingRecurrence" USING hash (billing_recurrence_id); diff --git a/db/src/main/resources/sql/flyway/V201__domain_hash.sql b/db/src/main/resources/sql/flyway/V201__domain_hash.sql new file mode 100644 index 000000000..bf1dd785c --- /dev/null +++ b/db/src/main/resources/sql/flyway/V201__domain_hash.sql @@ -0,0 +1,17 @@ +-- Copyright 2025 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. + +-- Add hash indexes on columns that are commonly queried with a direct equals +CREATE INDEX CONCURRENTLY IF NOT EXISTS domain_domain_name_hash ON "Domain" USING hash (domain_name); +CREATE INDEX CONCURRENTLY IF NOT EXISTS domain_domain_repo_id_hash ON "Domain" USING hash (repo_id); diff --git a/db/src/main/resources/sql/flyway/V202__delegation_signer_data_hash.sql b/db/src/main/resources/sql/flyway/V202__delegation_signer_data_hash.sql new file mode 100644 index 000000000..a9dacf5a2 --- /dev/null +++ b/db/src/main/resources/sql/flyway/V202__delegation_signer_data_hash.sql @@ -0,0 +1,16 @@ +-- Copyright 2025 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. + +-- Add hash indexes on columns that are commonly queried with a direct equals +CREATE INDEX CONCURRENTLY IF NOT EXISTS delegationsignerdata_domain_repo_id_hash ON "DelegationSignerData" USING hash (domain_repo_id); diff --git a/db/src/main/resources/sql/flyway/V203__domain_history_hash.sql b/db/src/main/resources/sql/flyway/V203__domain_history_hash.sql new file mode 100644 index 000000000..905c53524 --- /dev/null +++ b/db/src/main/resources/sql/flyway/V203__domain_history_hash.sql @@ -0,0 +1,17 @@ +-- Copyright 2025 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. + +-- Add hash indexes on columns that are commonly queried with a direct equals +CREATE INDEX CONCURRENTLY IF NOT EXISTS domainhistory_domain_repo_id_hash ON "DomainHistory" USING hash (domain_repo_id); +CREATE INDEX CONCURRENTLY IF NOT EXISTS domainhistory_history_revision_id_hash ON "DomainHistory" USING hash (history_revision_id); diff --git a/db/src/main/resources/sql/flyway/V204__domain_host_hash.sql b/db/src/main/resources/sql/flyway/V204__domain_host_hash.sql new file mode 100644 index 000000000..fa615522a --- /dev/null +++ b/db/src/main/resources/sql/flyway/V204__domain_host_hash.sql @@ -0,0 +1,16 @@ +-- Copyright 2025 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. + +-- Add hash indexes on columns that are commonly queried with a direct equals +CREATE INDEX CONCURRENTLY IF NOT EXISTS domainhost_domain_repo_id_hash ON "DomainHost" USING hash (domain_repo_id); diff --git a/db/src/main/resources/sql/flyway/V205__domain_transaction_record_hash.sql b/db/src/main/resources/sql/flyway/V205__domain_transaction_record_hash.sql new file mode 100644 index 000000000..d1c79a4a2 --- /dev/null +++ b/db/src/main/resources/sql/flyway/V205__domain_transaction_record_hash.sql @@ -0,0 +1,17 @@ +-- Copyright 2025 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. + +-- Add hash indexes on columns that are commonly queried with a direct equals +CREATE INDEX CONCURRENTLY IF NOT EXISTS domaintransactionrecord_id_hash ON "DomainTransactionRecord" USING hash (id); +CREATE INDEX CONCURRENTLY IF NOT EXISTS domaintransactionrecord_domain_history_revision_id_hash ON "DomainTransactionRecord" USING hash (history_revision_id); diff --git a/db/src/main/resources/sql/flyway/V206__grace_period_hash.sql b/db/src/main/resources/sql/flyway/V206__grace_period_hash.sql new file mode 100644 index 000000000..d6b54ee83 --- /dev/null +++ b/db/src/main/resources/sql/flyway/V206__grace_period_hash.sql @@ -0,0 +1,17 @@ +-- Copyright 2025 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. + +-- Add hash indexes on columns that are commonly queried with a direct equals +CREATE INDEX CONCURRENTLY IF NOT EXISTS graceperiod_grace_period_id_hash ON "GracePeriod" USING hash (grace_period_id); +CREATE INDEX CONCURRENTLY IF NOT EXISTS graceperiod_domain_repo_id_hash ON "GracePeriod" USING hash (domain_repo_id); diff --git a/db/src/main/resources/sql/flyway/V207__grace_period_history_hash.sql b/db/src/main/resources/sql/flyway/V207__grace_period_history_hash.sql new file mode 100644 index 000000000..42e8359aa --- /dev/null +++ b/db/src/main/resources/sql/flyway/V207__grace_period_history_hash.sql @@ -0,0 +1,16 @@ +-- Copyright 2025 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. + +-- Add hash indexes on columns that are commonly queried with a direct equals +CREATE INDEX CONCURRENTLY IF NOT EXISTS graceperiodhistory_grace_period_history_revision_id_hash ON "GracePeriodHistory" USING hash (grace_period_history_revision_id); diff --git a/db/src/main/resources/sql/flyway/V208__host_hash.sql b/db/src/main/resources/sql/flyway/V208__host_hash.sql new file mode 100644 index 000000000..d660fb8ad --- /dev/null +++ b/db/src/main/resources/sql/flyway/V208__host_hash.sql @@ -0,0 +1,17 @@ +-- Copyright 2025 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. + +-- Add hash indexes on columns that are commonly queried with a direct equals +CREATE INDEX CONCURRENTLY IF NOT EXISTS host_host_name_hash ON "Host" USING hash (host_name); +CREATE INDEX CONCURRENTLY IF NOT EXISTS host_repo_id_hash ON "Host" USING hash (repo_id); diff --git a/db/src/main/resources/sql/flyway/V209__poll_message_hash.sql b/db/src/main/resources/sql/flyway/V209__poll_message_hash.sql new file mode 100644 index 000000000..8912ad844 --- /dev/null +++ b/db/src/main/resources/sql/flyway/V209__poll_message_hash.sql @@ -0,0 +1,16 @@ +-- Copyright 2025 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. + +-- Add hash indexes on columns that are commonly queried with a direct equals +CREATE INDEX CONCURRENTLY IF NOT EXISTS pollmessage_poll_message_id_hash ON "PollMessage" USING hash (poll_message_id); diff --git a/db/src/main/resources/sql/schema/nomulus.golden.sql b/db/src/main/resources/sql/schema/nomulus.golden.sql index 822abbf8e..526734299 100644 --- a/db/src/main/resources/sql/schema/nomulus.golden.sql +++ b/db/src/main/resources/sql/schema/nomulus.golden.sql @@ -1924,6 +1924,48 @@ ALTER TABLE ONLY public."User" CREATE INDEX allocation_token_domain_name_idx ON public."AllocationToken" USING btree (domain_name); +-- +-- Name: billingcancellation_billing_cancellation_id_hash; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX billingcancellation_billing_cancellation_id_hash ON public."BillingCancellation" USING hash (billing_cancellation_id); + + +-- +-- Name: billingevent_billing_event_id_hash; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX billingevent_billing_event_id_hash ON public."BillingEvent" USING hash (billing_event_id); + + +-- +-- Name: billingrecurrence_billing_recurrence_id_hash; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX billingrecurrence_billing_recurrence_id_hash ON public."BillingRecurrence" USING hash (billing_recurrence_id); + + +-- +-- Name: delegationsignerdata_domain_repo_id_hash; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX delegationsignerdata_domain_repo_id_hash ON public."DelegationSignerData" USING hash (domain_repo_id); + + +-- +-- Name: domain_domain_name_hash; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX domain_domain_name_hash ON public."Domain" USING hash (domain_name); + + +-- +-- Name: domain_domain_repo_id_hash; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX domain_domain_repo_id_hash ON public."Domain" USING hash (repo_id); + + -- -- Name: domain_history_to_ds_data_history_idx; Type: INDEX; Schema: public; Owner: - -- @@ -1938,6 +1980,76 @@ CREATE INDEX domain_history_to_ds_data_history_idx ON public."DomainDsDataHistor CREATE INDEX domain_history_to_transaction_record_idx ON public."DomainTransactionRecord" USING btree (domain_repo_id, history_revision_id); +-- +-- Name: domainhistory_domain_repo_id_hash; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX domainhistory_domain_repo_id_hash ON public."DomainHistory" USING hash (domain_repo_id); + + +-- +-- Name: domainhistory_history_revision_id_hash; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX domainhistory_history_revision_id_hash ON public."DomainHistory" USING hash (history_revision_id); + + +-- +-- Name: domainhost_domain_repo_id_hash; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX domainhost_domain_repo_id_hash ON public."DomainHost" USING hash (domain_repo_id); + + +-- +-- Name: domaintransactionrecord_domain_history_revision_id_hash; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX domaintransactionrecord_domain_history_revision_id_hash ON public."DomainTransactionRecord" USING hash (history_revision_id); + + +-- +-- Name: domaintransactionrecord_id_hash; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX domaintransactionrecord_id_hash ON public."DomainTransactionRecord" USING hash (id); + + +-- +-- Name: graceperiod_domain_repo_id_hash; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX graceperiod_domain_repo_id_hash ON public."GracePeriod" USING hash (domain_repo_id); + + +-- +-- Name: graceperiod_grace_period_id_hash; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX graceperiod_grace_period_id_hash ON public."GracePeriod" USING hash (grace_period_id); + + +-- +-- Name: graceperiodhistory_grace_period_history_revision_id_hash; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX graceperiodhistory_grace_period_history_revision_id_hash ON public."GracePeriodHistory" USING hash (grace_period_history_revision_id); + + +-- +-- Name: host_host_name_hash; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX host_host_name_hash ON public."Host" USING hash (host_name); + + +-- +-- Name: host_repo_id_hash; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX host_repo_id_hash ON public."Host" USING hash (repo_id); + + -- -- Name: idx1dyqmqb61xbnj7mt7bk27ds25; Type: INDEX; Schema: public; Owner: - -- @@ -2617,6 +2729,13 @@ CREATE INDEX idxtmlqd31dpvvd2g1h9i7erw6aj ON public."AllocationToken" USING btre CREATE INDEX idxy98mebut8ix1v07fjxxdkqcx ON public."Host" USING btree (creation_time); +-- +-- Name: pollmessage_poll_message_id_hash; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX pollmessage_poll_message_id_hash ON public."PollMessage" USING hash (poll_message_id); + + -- -- Name: premiumlist_name_idx; Type: INDEX; Schema: public; Owner: - --