From a94579fb3a3554b31b59bf19bbdeb23bfdc61924 Mon Sep 17 00:00:00 2001 From: Gus Brodman Date: Mon, 29 Dec 2025 17:51:29 -0500 Subject: [PATCH] Add indexes on current_package_token in Domain* It just makes it possible to delete allocation tokens, otherwise we need to do a linear search over the entire Domain and DomainHistory tables if we ever want to delete something. --- .../sql/er_diagram/brief_er_diagram.html | 6 ++-- .../sql/er_diagram/full_er_diagram.html | 30 +++++++++++++++++-- db/src/main/resources/sql/flyway.txt | 2 ++ ...V219__domain_history_package_token_idx.sql | 16 ++++++++++ .../flyway/V220__domain_package_token_idx.sql | 16 ++++++++++ .../resources/sql/schema/nomulus.golden.sql | 14 +++++++++ 6 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 db/src/main/resources/sql/flyway/V219__domain_history_package_token_idx.sql create mode 100644 db/src/main/resources/sql/flyway/V220__domain_package_token_idx.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 b306d592bf7..1775d101e20 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 @@

System Information

generated on - 2025-11-14 20:23:12 + 2026-01-01 02:43:24 last flyway file - V218__tld_drop_allowedregistrantcontactids.sql + V220__domain_package_token_idx.sql @@ -273,7 +273,7 @@

System Information

 

- SchemaCrawler_Diagram generated by SchemaCrawler 16.27.1 generated on 2025-11-14 20:23:12 + SchemaCrawler_Diagram generated by SchemaCrawler 16.27.1 generated on 2026-01-01 02:43:24 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 d80020721cb..3f31e3b6252 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 @@

System Information

generated on - 2025-11-14 20:23:09 + 2026-01-01 02:43:21 last flyway file - V218__tld_drop_allowedregistrantcontactids.sql + V220__domain_package_token_idx.sql @@ -273,7 +273,7 @@

System Information

 

- SchemaCrawler_Diagram generated by SchemaCrawler 16.27.1 generated on 2025-11-14 20:23:09 + SchemaCrawler_Diagram generated by SchemaCrawler 16.27.1 generated on 2026-01-01 02:43:21 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 @@ -4466,6 +4466,18 @@

Tables

+ + domain_current_package_token_idx + [non-unique hashed index] + + + + current_package_token + unknown + + + + idxkjt9yaq92876dstimd93hwckh [non-unique index] @@ -5195,6 +5207,18 @@

Tables

+ + domainhistory_current_package_token_idx + [non-unique hashed index] + + + + current_package_token + unknown + + + + domainhistory_domain_repo_id_hash [non-unique hashed index] diff --git a/db/src/main/resources/sql/flyway.txt b/db/src/main/resources/sql/flyway.txt index 8eff36f9a32..6b898a3e937 100644 --- a/db/src/main/resources/sql/flyway.txt +++ b/db/src/main/resources/sql/flyway.txt @@ -216,3 +216,5 @@ V215__drop_contact_fks_contacthistory.sql V216__drop_contact_fks_domain.sql V217__drop_contact_fks_pollmessage.sql V218__tld_drop_allowedregistrantcontactids.sql +V219__domain_history_package_token_idx.sql +V220__domain_package_token_idx.sql diff --git a/db/src/main/resources/sql/flyway/V219__domain_history_package_token_idx.sql b/db/src/main/resources/sql/flyway/V219__domain_history_package_token_idx.sql new file mode 100644 index 00000000000..13ae5653b9e --- /dev/null +++ b/db/src/main/resources/sql/flyway/V219__domain_history_package_token_idx.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. + +CREATE INDEX CONCURRENTLY IF NOT EXISTS domainhistory_current_package_token_idx ON "DomainHistory" + USING hash(current_package_token); diff --git a/db/src/main/resources/sql/flyway/V220__domain_package_token_idx.sql b/db/src/main/resources/sql/flyway/V220__domain_package_token_idx.sql new file mode 100644 index 00000000000..69ca3d594b7 --- /dev/null +++ b/db/src/main/resources/sql/flyway/V220__domain_package_token_idx.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. + +CREATE INDEX CONCURRENTLY IF NOT EXISTS domain_current_package_token_idx ON "Domain" + USING hash(current_package_token); diff --git a/db/src/main/resources/sql/schema/nomulus.golden.sql b/db/src/main/resources/sql/schema/nomulus.golden.sql index b88c8059b9c..6a191b1d9f9 100644 --- a/db/src/main/resources/sql/schema/nomulus.golden.sql +++ b/db/src/main/resources/sql/schema/nomulus.golden.sql @@ -1958,6 +1958,13 @@ CREATE INDEX billingrecurrence_billing_recurrence_id_hash ON public."BillingRecu CREATE INDEX delegationsignerdata_domain_repo_id_hash ON public."DelegationSignerData" USING hash (domain_repo_id); +-- +-- Name: domain_current_package_token_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX domain_current_package_token_idx ON public."Domain" USING hash (current_package_token); + + -- -- Name: domain_domain_name_hash; Type: INDEX; Schema: public; Owner: - -- @@ -2000,6 +2007,13 @@ CREATE UNIQUE INDEX domain_no_duplicate_active ON public."Domain" USING btree (d CREATE INDEX domaindsdatahistory_domain_history_revision_id_hash ON public."DomainDsDataHistory" USING hash (domain_history_revision_id); +-- +-- Name: domainhistory_current_package_token_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX domainhistory_current_package_token_idx ON public."DomainHistory" USING hash (current_package_token); + + -- -- Name: domainhistory_domain_repo_id_hash; Type: INDEX; Schema: public; Owner: - --