Skip to content

Commit a94579f

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 7e9d4c2 commit a94579f

File tree

6 files changed

+78
-6
lines changed

6 files changed

+78
-6
lines changed

db/src/main/resources/sql/er_diagram/brief_er_diagram.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,19 +261,19 @@ <h2>System Information</h2>
261261
</tr>
262262
<tr>
263263
<td class="property_name">generated on</td>
264-
<td class="property_value">2025-11-14 20:23:12</td>
264+
<td class="property_value">2026-01-01 02:43:24</td>
265265
</tr>
266266
<tr>
267267
<td class="property_name">last flyway file</td>
268-
<td id="lastFlywayFile" class="property_value">V218__tld_drop_allowedregistrantcontactids.sql</td>
268+
<td id="lastFlywayFile" class="property_value">V220__domain_package_token_idx.sql</td>
269269
</tr>
270270
</tbody>
271271
</table>
272272
<p>&nbsp;</p>
273273
<p>&nbsp;</p>
274274
<svg viewBox="0.00 0.00 4846.00 3765.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="erDiagram" style="overflow: hidden; width: 100%; height: 800px">
275275
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 3761)">
276-
<title>SchemaCrawler_Diagram</title> <polygon fill="white" stroke="transparent" points="-4,4 -4,-3761 4842,-3761 4842,4 -4,4" /> <text text-anchor="start" x="4598" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">generated by</text> <text text-anchor="start" x="4681" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">SchemaCrawler 16.27.1</text> <text text-anchor="start" x="4597" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">generated on</text> <text text-anchor="start" x="4681" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">2025-11-14 20:23:12</text> <polygon fill="none" stroke="#888888" points="4594,-4 4594,-44 4830,-44 4830,-4 4594,-4" /> <!-- allocationtoken_a08ccbef -->
276+
<title>SchemaCrawler_Diagram</title> <polygon fill="white" stroke="transparent" points="-4,4 -4,-3761 4842,-3761 4842,4 -4,4" /> <text text-anchor="start" x="4598" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">generated by</text> <text text-anchor="start" x="4681" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">SchemaCrawler 16.27.1</text> <text text-anchor="start" x="4597" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">generated on</text> <text text-anchor="start" x="4681" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">2026-01-01 02:43:24</text> <polygon fill="none" stroke="#888888" points="4594,-4 4594,-44 4830,-44 4830,-4 4594,-4" /> <!-- allocationtoken_a08ccbef -->
277277
<g id="node1" class="node">
278278
<title>allocationtoken_a08ccbef</title> <polygon fill="#e9c2f2" stroke="transparent" points="525.5,-1272 525.5,-1291 711.5,-1291 711.5,-1272 525.5,-1272" /> <text text-anchor="start" x="527.5" y="-1278.8" font-family="Helvetica,sans-Serif" font-weight="bold" font-style="italic" font-size="14.00">public."AllocationToken"</text> <polygon fill="#e9c2f2" stroke="transparent" points="711.5,-1272 711.5,-1291 785.5,-1291 785.5,-1272 711.5,-1272" /> <text text-anchor="start" x="746.5" y="-1277.8" font-family="Helvetica,sans-Serif" font-size="14.00">[table]</text> <text text-anchor="start" x="527.5" y="-1259.8" font-family="Helvetica,sans-Serif" font-weight="bold" font-style="italic" font-size="14.00">token</text> <text text-anchor="start" x="705.5" y="-1258.8" font-family="Helvetica,sans-Serif" font-size="14.00"> </text> <text text-anchor="start" x="713.5" y="-1258.8" font-family="Helvetica,sans-Serif" font-size="14.00">text not null</text> <text text-anchor="start" x="527.5" y="-1239.8" font-family="Helvetica,sans-Serif" font-size="14.00">domain_name</text> <text text-anchor="start" x="705.5" y="-1239.8" font-family="Helvetica,sans-Serif" font-size="14.00"> </text> <text text-anchor="start" x="713.5" y="-1239.8" font-family="Helvetica,sans-Serif" font-size="14.00">text</text> <text text-anchor="start" x="527.5" y="-1220.8" font-family="Helvetica,sans-Serif" font-size="14.00">redemption_domain_repo_id</text> <text text-anchor="start" x="705.5" y="-1220.8" font-family="Helvetica,sans-Serif" font-size="14.00"> </text> <text text-anchor="start" x="713.5" y="-1220.8" font-family="Helvetica,sans-Serif" font-size="14.00">text</text> <text text-anchor="start" x="527.5" y="-1201.8" font-family="Helvetica,sans-Serif" font-size="14.00">token_type</text> <text text-anchor="start" x="705.5" y="-1201.8" font-family="Helvetica,sans-Serif" font-size="14.00"> </text> <text text-anchor="start" x="713.5" y="-1201.8" font-family="Helvetica,sans-Serif" font-size="14.00">text</text> <polygon fill="none" stroke="#888888" points="524.5,-1195.5 524.5,-1292.5 786.5,-1292.5 786.5,-1195.5 524.5,-1195.5" />
279279
</g>

db/src/main/resources/sql/er_diagram/full_er_diagram.html

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,19 +261,19 @@ <h2>System Information</h2>
261261
</tr>
262262
<tr>
263263
<td class="property_name">generated on</td>
264-
<td class="property_value">2025-11-14 20:23:09</td>
264+
<td class="property_value">2026-01-01 02:43:21</td>
265265
</tr>
266266
<tr>
267267
<td class="property_name">last flyway file</td>
268-
<td id="lastFlywayFile" class="property_value">V218__tld_drop_allowedregistrantcontactids.sql</td>
268+
<td id="lastFlywayFile" class="property_value">V220__domain_package_token_idx.sql</td>
269269
</tr>
270270
</tbody>
271271
</table>
272272
<p>&nbsp;</p>
273273
<p>&nbsp;</p>
274274
<svg viewBox="0.00 0.00 5572.00 9932.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="erDiagram" style="overflow: hidden; width: 100%; height: 800px">
275275
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 9928)">
276-
<title>SchemaCrawler_Diagram</title> <polygon fill="white" stroke="transparent" points="-4,4 -4,-9928 5568,-9928 5568,4 -4,4" /> <text text-anchor="start" x="5324" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">generated by</text> <text text-anchor="start" x="5407" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">SchemaCrawler 16.27.1</text> <text text-anchor="start" x="5323" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">generated on</text> <text text-anchor="start" x="5407" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">2025-11-14 20:23:09</text> <polygon fill="none" stroke="#888888" points="5320,-4 5320,-44 5556,-44 5556,-4 5320,-4" /> <!-- allocationtoken_a08ccbef -->
276+
<title>SchemaCrawler_Diagram</title> <polygon fill="white" stroke="transparent" points="-4,4 -4,-9928 5568,-9928 5568,4 -4,4" /> <text text-anchor="start" x="5324" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">generated by</text> <text text-anchor="start" x="5407" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">SchemaCrawler 16.27.1</text> <text text-anchor="start" x="5323" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">generated on</text> <text text-anchor="start" x="5407" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">2026-01-01 02:43:21</text> <polygon fill="none" stroke="#888888" points="5320,-4 5320,-44 5556,-44 5556,-4 5320,-4" /> <!-- allocationtoken_a08ccbef -->
277277
<g id="node1" class="node">
278278
<title>allocationtoken_a08ccbef</title> <polygon fill="#e9c2f2" stroke="transparent" points="790,-5020 790,-5039 989,-5039 989,-5020 790,-5020" /> <text text-anchor="start" x="792" y="-5026.8" font-family="Helvetica,sans-Serif" font-weight="bold" font-style="italic" font-size="14.00">public."AllocationToken"</text> <polygon fill="#e9c2f2" stroke="transparent" points="989,-5020 989,-5039 1120,-5039 1120,-5020 989,-5020" /> <text text-anchor="start" x="1081" y="-5025.8" font-family="Helvetica,sans-Serif" font-size="14.00">[table]</text> <text text-anchor="start" x="792" y="-5007.8" font-family="Helvetica,sans-Serif" font-weight="bold" font-style="italic" font-size="14.00">token</text> <text text-anchor="start" x="983" y="-5006.8" font-family="Helvetica,sans-Serif" font-size="14.00"> </text> <text text-anchor="start" x="991" y="-5006.8" font-family="Helvetica,sans-Serif" font-size="14.00">text not null</text> <text text-anchor="start" x="792" y="-4987.8" font-family="Helvetica,sans-Serif" font-size="14.00">update_timestamp</text> <text text-anchor="start" x="983" y="-4987.8" font-family="Helvetica,sans-Serif" font-size="14.00"> </text> <text text-anchor="start" x="991" y="-4987.8" font-family="Helvetica,sans-Serif" font-size="14.00">timestamptz</text> <text text-anchor="start" x="792" y="-4968.8" font-family="Helvetica,sans-Serif" font-size="14.00">allowed_registrar_ids</text> <text text-anchor="start" x="983" y="-4968.8" font-family="Helvetica,sans-Serif" font-size="14.00"> </text> <text text-anchor="start" x="991" y="-4968.8" font-family="Helvetica,sans-Serif" font-size="14.00">_text</text> <text text-anchor="start" x="792" y="-4949.8" font-family="Helvetica,sans-Serif" font-size="14.00">allowed_tlds</text> <text text-anchor="start" x="983" y="-4949.8" font-family="Helvetica,sans-Serif" font-size="14.00"> </text> <text text-anchor="start" x="991" y="-4949.8" font-family="Helvetica,sans-Serif" font-size="14.00">_text</text> <text text-anchor="start" x="792" y="-4930.8" font-family="Helvetica,sans-Serif" font-size="14.00">creation_time</text> <text text-anchor="start" x="983" y="-4930.8" font-family="Helvetica,sans-Serif" font-size="14.00"> </text> <text text-anchor="start" x="991" y="-4930.8" font-family="Helvetica,sans-Serif" font-size="14.00">timestamptz not null</text> <text text-anchor="start" x="792" y="-4911.8" font-family="Helvetica,sans-Serif" font-size="14.00">discount_fraction</text> <text text-anchor="start" x="983" y="-4911.8" font-family="Helvetica,sans-Serif" font-size="14.00"> </text> <text text-anchor="start" x="991" y="-4911.8" font-family="Helvetica,sans-Serif" font-size="14.00">float8(17, 17) not null</text> <text text-anchor="start" x="792" y="-4892.8" font-family="Helvetica,sans-Serif" font-size="14.00">discount_premiums</text> <text text-anchor="start" x="983" y="-4892.8" font-family="Helvetica,sans-Serif" font-size="14.00"> </text> <text text-anchor="start" x="991" y="-4892.8" font-family="Helvetica,sans-Serif" font-size="14.00">bool not null</text> <text text-anchor="start" x="792" y="-4873.8" font-family="Helvetica,sans-Serif" font-size="14.00">discount_years</text> <text text-anchor="start" x="983" y="-4873.8" font-family="Helvetica,sans-Serif" font-size="14.00"> </text> <text text-anchor="start" x="991" y="-4873.8" font-family="Helvetica,sans-Serif" font-size="14.00">int4 not null</text> <text text-anchor="start" x="792" y="-4854.8" font-family="Helvetica,sans-Serif" font-size="14.00">domain_name</text> <text text-anchor="start" x="983" y="-4854.8" font-family="Helvetica,sans-Serif" font-size="14.00"> </text> <text text-anchor="start" x="991" y="-4854.8" font-family="Helvetica,sans-Serif" font-size="14.00">text</text> <text text-anchor="start" x="792" y="-4835.8" font-family="Helvetica,sans-Serif" font-size="14.00">redemption_domain_repo_id</text> <text text-anchor="start" x="983" y="-4835.8" font-family="Helvetica,sans-Serif" font-size="14.00"> </text> <text text-anchor="start" x="991" y="-4835.8" font-family="Helvetica,sans-Serif" font-size="14.00">text</text> <text text-anchor="start" x="792" y="-4816.8" font-family="Helvetica,sans-Serif" font-size="14.00">token_status_transitions</text> <text text-anchor="start" x="983" y="-4816.8" font-family="Helvetica,sans-Serif" font-size="14.00"> </text> <text text-anchor="start" x="991" y="-4816.8" font-family="Helvetica,sans-Serif" font-size="14.00">hstore</text> <text text-anchor="start" x="792" y="-4797.8" font-family="Helvetica,sans-Serif" font-size="14.00">token_type</text> <text text-anchor="start" x="983" y="-4797.8" font-family="Helvetica,sans-Serif" font-size="14.00"> </text> <text text-anchor="start" x="991" y="-4797.8" font-family="Helvetica,sans-Serif" font-size="14.00">text</text> <text text-anchor="start" x="792" y="-4778.8" font-family="Helvetica,sans-Serif" font-size="14.00">redemption_domain_history_id</text> <text text-anchor="start" x="983" y="-4778.8" font-family="Helvetica,sans-Serif" font-size="14.00"> </text> <text text-anchor="start" x="991" y="-4778.8" font-family="Helvetica,sans-Serif" font-size="14.00">int8</text> <text text-anchor="start" x="792" y="-4759.8" font-family="Helvetica,sans-Serif" font-size="14.00">renewal_price_behavior</text> <text text-anchor="start" x="983" y="-4759.8" font-family="Helvetica,sans-Serif" font-size="14.00"> </text> <text text-anchor="start" x="991" y="-4759.8" font-family="Helvetica,sans-Serif" font-size="14.00">text not null</text> <text text-anchor="start" x="792" y="-4740.8" font-family="Helvetica,sans-Serif" font-size="14.00">registration_behavior</text> <text text-anchor="start" x="983" y="-4740.8" font-family="Helvetica,sans-Serif" font-size="14.00"> </text> <text text-anchor="start" x="991" y="-4740.8" font-family="Helvetica,sans-Serif" font-size="14.00">text not null</text> <text text-anchor="start" x="792" y="-4721.8" font-family="Helvetica,sans-Serif" font-size="14.00">allowed_epp_actions</text> <text text-anchor="start" x="983" y="-4721.8" font-family="Helvetica,sans-Serif" font-size="14.00"> </text> <text text-anchor="start" x="991" y="-4721.8" font-family="Helvetica,sans-Serif" font-size="14.00">_text</text> <text text-anchor="start" x="792" y="-4702.8" font-family="Helvetica,sans-Serif" font-size="14.00">renewal_price_amount</text> <text text-anchor="start" x="983" y="-4702.8" font-family="Helvetica,sans-Serif" font-size="14.00"> </text> <text text-anchor="start" x="991" y="-4702.8" font-family="Helvetica,sans-Serif" font-size="14.00">numeric(19, 2)</text> <text text-anchor="start" x="792" y="-4683.8" font-family="Helvetica,sans-Serif" font-size="14.00">renewal_price_currency</text> <text text-anchor="start" x="983" y="-4683.8" font-family="Helvetica,sans-Serif" font-size="14.00"> </text> <text text-anchor="start" x="991" y="-4683.8" font-family="Helvetica,sans-Serif" font-size="14.00">text</text> <text text-anchor="start" x="792" y="-4664.8" font-family="Helvetica,sans-Serif" font-size="14.00">discount_price_amount</text> <text text-anchor="start" x="983" y="-4664.8" font-family="Helvetica,sans-Serif" font-size="14.00"> </text> <text text-anchor="start" x="991" y="-4664.8" font-family="Helvetica,sans-Serif" font-size="14.00">numeric(19, 2)</text> <text text-anchor="start" x="792" y="-4645.8" font-family="Helvetica,sans-Serif" font-size="14.00">discount_price_currency</text> <text text-anchor="start" x="983" y="-4645.8" font-family="Helvetica,sans-Serif" font-size="14.00"> </text> <text text-anchor="start" x="991" y="-4645.8" font-family="Helvetica,sans-Serif" font-size="14.00">text</text> <polygon fill="none" stroke="#888888" points="789,-4639.5 789,-5040.5 1121,-5040.5 1121,-4639.5 789,-4639.5" />
279279
</g>
@@ -4466,6 +4466,18 @@ <h2>Tables</h2>
44664466
<tr>
44674467
<td colspan="3"></td>
44684468
</tr>
4469+
<tr>
4470+
<td colspan="2" class="name">domain_current_package_token_idx</td>
4471+
<td class="description right">[non-unique hashed index]</td>
4472+
</tr>
4473+
<tr>
4474+
<td class="spacer"></td>
4475+
<td class="minwidth">current_package_token</td>
4476+
<td class="minwidth">unknown</td>
4477+
</tr>
4478+
<tr>
4479+
<td colspan="3"></td>
4480+
</tr>
44694481
<tr>
44704482
<td colspan="2" class="name">idxkjt9yaq92876dstimd93hwckh</td>
44714483
<td class="description right">[non-unique index]</td>
@@ -5195,6 +5207,18 @@ <h2>Tables</h2>
51955207
<tr>
51965208
<td colspan="3"></td>
51975209
</tr>
5210+
<tr>
5211+
<td colspan="2" class="name">domainhistory_current_package_token_idx</td>
5212+
<td class="description right">[non-unique hashed index]</td>
5213+
</tr>
5214+
<tr>
5215+
<td class="spacer"></td>
5216+
<td class="minwidth">current_package_token</td>
5217+
<td class="minwidth">unknown</td>
5218+
</tr>
5219+
<tr>
5220+
<td colspan="3"></td>
5221+
</tr>
51985222
<tr>
51995223
<td colspan="2" class="name">domainhistory_domain_repo_id_hash</td>
52005224
<td class="description right">[non-unique hashed index]</td>

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)