Skip to content

Commit 7e50379

Browse files
committed
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.
1 parent 6f0bc1d commit 7e50379

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

db/src/main/resources/sql/flyway.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,5 @@ V215__drop_contact_fks_contacthistory.sql
216216
V216__drop_contact_fks_domain.sql
217217
V217__drop_contact_fks_pollmessage.sql
218218
V218__tld_drop_allowedregistrantcontactids.sql
219+
V219__domain_history_package_token_idx.sql
220+
V220__domain_package_token_idx.sql
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- Copyright 2025 The Nomulus Authors. All Rights Reserved.
2+
--
3+
-- Licensed under the Apache License, Version 2.0 (the "License");
4+
-- you may not use this file except in compliance with the License.
5+
-- You may obtain a copy of the License at
6+
--
7+
-- http://www.apache.org/licenses/LICENSE-2.0
8+
--
9+
-- Unless required by applicable law or agreed to in writing, software
10+
-- distributed under the License is distributed on an "AS IS" BASIS,
11+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
-- See the License for the specific language governing permissions and
13+
-- limitations under the License.
14+
15+
CREATE INDEX CONCURRENTLY IF NOT EXISTS domainhistory_current_package_token_idx ON "DomainHistory"
16+
USING hash(current_package_token);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- Copyright 2025 The Nomulus Authors. All Rights Reserved.
2+
--
3+
-- Licensed under the Apache License, Version 2.0 (the "License");
4+
-- you may not use this file except in compliance with the License.
5+
-- You may obtain a copy of the License at
6+
--
7+
-- http://www.apache.org/licenses/LICENSE-2.0
8+
--
9+
-- Unless required by applicable law or agreed to in writing, software
10+
-- distributed under the License is distributed on an "AS IS" BASIS,
11+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
-- See the License for the specific language governing permissions and
13+
-- limitations under the License.
14+
15+
CREATE INDEX CONCURRENTLY IF NOT EXISTS domain_current_package_token_idx ON "Domain"
16+
USING hash(current_package_token);

db/src/main/resources/sql/schema/nomulus.golden.sql

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,6 +1958,13 @@ CREATE INDEX billingrecurrence_billing_recurrence_id_hash ON public."BillingRecu
19581958
CREATE INDEX delegationsignerdata_domain_repo_id_hash ON public."DelegationSignerData" USING hash (domain_repo_id);
19591959

19601960

1961+
--
1962+
-- Name: domain_current_package_token_idx; Type: INDEX; Schema: public; Owner: -
1963+
--
1964+
1965+
CREATE INDEX domain_current_package_token_idx ON public."Domain" USING hash (current_package_token);
1966+
1967+
19611968
--
19621969
-- Name: domain_domain_name_hash; Type: INDEX; Schema: public; Owner: -
19631970
--
@@ -2000,6 +2007,13 @@ CREATE UNIQUE INDEX domain_no_duplicate_active ON public."Domain" USING btree (d
20002007
CREATE INDEX domaindsdatahistory_domain_history_revision_id_hash ON public."DomainDsDataHistory" USING hash (domain_history_revision_id);
20012008

20022009

2010+
--
2011+
-- Name: domainhistory_current_package_token_idx; Type: INDEX; Schema: public; Owner: -
2012+
--
2013+
2014+
CREATE INDEX domainhistory_current_package_token_idx ON public."DomainHistory" USING hash (current_package_token);
2015+
2016+
20032017
--
20042018
-- Name: domainhistory_domain_repo_id_hash; Type: INDEX; Schema: public; Owner: -
20052019
--

0 commit comments

Comments
 (0)