1
0
mirror of https://github.com/google/nomulus synced 2025-12-23 06:15:42 +00:00

Drop FKs referencing DomainHistory (#2621)

- We never delete rows from DomainHistory (and even if we do in the
  future, they'll be old / the references won't matter)
- This is likely creating lock contention when lots of requests come
  through at once for domains with many DomainHistory entries
This commit is contained in:
gbrodman
2024-12-10 13:46:48 -05:00
committed by GitHub
parent fce126d426
commit c6a6bc7e25
19 changed files with 4939 additions and 5635 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -177,3 +177,10 @@ V176__drop_login_email_address_column_from_registrar_poc.sql
V177__drop_user_id.sql
V178__drop_user_id_history.sql
V179__add_discount_price_allocation_token.sql
V180__remove_fk_graceperiodhistory_domainhistory.sql
V181__remove_fk_billingcancellation_domainhistory.sql
V182__remove_fk_billingevent_domainhistory.sql
V183__remove_fk_billingrecurrence_domainhistory.sql
V184__remove_fk_pollmessage_domainhistory.sql
V185__remove_fk_domaintransactionrecord_domainhistory.sql
V186__remove_fk_domaindsdatahistory_domainhistory.sql

View File

@@ -0,0 +1,16 @@
-- Copyright 2024 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.
ALTER TABLE "GracePeriodHistory" DROP CONSTRAINT fk7w3cx8d55q8bln80e716tr7b8;
CREATE INDEX IDXl67y6wclc2uaupepnvkoo81fl on "GracePeriodHistory" (domain_repo_id, domain_history_revision_id);

View File

@@ -0,0 +1,16 @@
-- Copyright 2024 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.
ALTER TABLE "BillingCancellation" DROP CONSTRAINT fk_billing_cancellation_domain_history;
CREATE INDEX IDX7v75e535c47mxfb2rk9o843bn ON"BillingCancellation" (domain_repo_id, domain_history_revision_id);

View File

@@ -0,0 +1,18 @@
-- Copyright 2024 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.
ALTER TABLE "BillingEvent" DROP CONSTRAINT fk_billing_event_domain_history;
ALTER TABLE "BillingEvent" DROP CONSTRAINT fk_billing_event_recurrence_history;
CREATE INDEX IDX77ceolnf7rok8ui957msmo6en ON "BillingEvent" (domain_repo_id, domain_history_revision_id);
CREATE INDEX IDXehp8ejwpbsooar0e8k32847m3 ON "BillingEvent" (domain_repo_id, recurrence_history_revision_id);

View File

@@ -0,0 +1,16 @@
-- Copyright 2024 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.
ALTER TABLE "BillingRecurrence" DROP CONSTRAINT fk_billing_recurrence_domain_history;
CREATE INDEX IDXlh9lvmxb2dj3ti83buauwvbil ON "BillingRecurrence" (domain_repo_id, domain_history_revision_id);

View File

@@ -0,0 +1,16 @@
-- Copyright 2024 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.
ALTER TABLE "PollMessage" DROP CONSTRAINT fk_poll_message_domain_history;
CREATE INDEX IDXnuyqo6hrtuvbcmuecf7vkfmle ON "PollMessage" (domain_repo_id, domain_history_revision_id);

View File

@@ -0,0 +1,16 @@
-- Copyright 2024 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.
ALTER TABLE "DomainTransactionRecord" DROP CONSTRAINT "fkcjqe54u72kha71vkibvxhjye7";
CREATE INDEX IDX1dyqmqb61xbnj7mt7bk27ds25 ON "DomainTransactionRecord" (domain_repo_id, history_revision_id);

View File

@@ -0,0 +1,16 @@
-- Copyright 2024 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.
ALTER TABLE "DomainDsDataHistory" DROP CONSTRAINT fko4ilgyyfnvppbpuivus565i0j;
CREATE INDEX IDXmk1d2ngdtfkg6odmw7l5ejisw ON "DomainDsDataHistory" (domain_repo_id, domain_history_revision_id);

View File

@@ -941,12 +941,15 @@
create index IDXqa3g92jc17e8dtiaviy4fet4x
on "BillingCancellation" (billing_time);
create index IDX4ytbe5f3b39trsd4okx5ijhs4
create index IDX4muirjyj3kt8nx63nrjxigktk
on "BillingCancellation" (billing_event_id);
create index IDXku0fopwyvd57ebo8bf0jg9xo2
create index IDXmfu2k59a54e0ttoxchwaci7qy
on "BillingCancellation" (billing_recurrence_id);
create index IDX7v75e535c47mxfb2rk9o843bn
on "BillingCancellation" (domain_repo_id, domain_history_revision_id);
create index IDXqspv57gj2led8ly42fq01t7m7
on "BillingEvent" (registrar_id);
@@ -965,9 +968,15 @@
create index IDXcesda59ssop44kklytpb292hn
on "BillingEvent" (allocation_token);
create index IDX6ebt3nwk5ocvnremnhnlkl6ff
create index IDX80375qd9haxrvwk8ovqmp3695
on "BillingEvent" (cancellation_matching_billing_recurrence_id);
create index IDX77ceolnf7rok8ui957msmo6en
on "BillingEvent" (domain_repo_id, domain_history_revision_id);
create index IDXehp8ejwpbsooar0e8k32847m3
on "BillingEvent" (domain_repo_id, recurrence_history_revision_id);
create index IDXd3gxhkh0jk694pjvh9pyn7wjc
on "BillingRecurrence" (registrar_id);
@@ -983,9 +992,12 @@
create index IDXp0pxi708hlu4n40qhbtihge8x
on "BillingRecurrence" (recurrence_last_expansion);
create index IDXjny8wuot75b5e6p38r47wdawu
create index IDXbix949l2kfn9r03l6omyhi36f
on "BillingRecurrence" (recurrence_time_of_year);
create index IDXlh9lvmxb2dj3ti83buauwvbil
on "BillingRecurrence" (domain_repo_id, domain_history_revision_id);
create index IDXj874kw19bgdnkxo1rue45jwlw
on "BsaDownload" (creation_time);
@@ -1079,6 +1091,9 @@
create index IDXhteajcrxmq4o8rsys8kevyiqr
on "Domain" (transfer_billing_cancellation_id);
create index IDXmk1d2ngdtfkg6odmw7l5ejisw
on "DomainDsDataHistory" (domain_repo_id, domain_history_revision_id);
create index IDXrh4xmrot9bd63o382ow9ltfig
on "DomainHistory" (creation_time);
@@ -1097,6 +1112,9 @@
create index IDXjw3rwtfrexyq53x9vu7qghrdt
on "DomainHost" (host_repo_id);
create index IDX1dyqmqb61xbnj7mt7bk27ds25
on "DomainTransactionRecord" (domain_repo_id, history_revision_id);
create index IDXj1mtx98ndgbtb1bkekahms18w
on "GracePeriod" (domain_repo_id);
@@ -1109,6 +1127,9 @@
create index IDXd01j17vrpjxaerxdmn8bwxs7s
on "GracePeriodHistory" (domain_repo_id);
create index IDXl67y6wclc2uaupepnvkoo81fl
on "GracePeriodHistory" (domain_repo_id, domain_history_revision_id);
create index IDXkpkh68n6dy5v51047yr6b0e9l
on "Host" (host_name);
@@ -1145,12 +1166,15 @@
create index IDXf2q9dqj899h1q8lah5y719nxd
on "PollMessage" (domain_repo_id);
create index IDXe7wu46c7wpvfmfnj4565abibp
create index IDXb75725p8js6987ubi8a7nhdqs
on "PollMessage" (registrar_id);
create index IDXaydgox62uno9qx8cjlj5lauye
on "PollMessage" (event_time);
create index IDXnuyqo6hrtuvbcmuecf7vkfmle
on "PollMessage" (domain_repo_id, domain_history_revision_id);
create index premiumlist_name_idx
on "PremiumList" (name);

View File

@@ -1862,6 +1862,13 @@ 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: idx1dyqmqb61xbnj7mt7bk27ds25; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX idx1dyqmqb61xbnj7mt7bk27ds25 ON public."DomainTransactionRecord" USING btree (domain_repo_id, history_revision_id);
--
-- Name: idx1iy7njgb7wjmj9piml4l2g0qi; Type: INDEX; Schema: public; Owner: -
--
@@ -2002,6 +2009,20 @@ CREATE INDEX idx6y67d6wsffmr6jcxax5ghwqhd ON public."ConsoleEppActionHistory" US
CREATE INDEX idx73l103vc5900ig3p4odf0cngt ON public."BillingEvent" USING btree (registrar_id);
--
-- Name: idx77ceolnf7rok8ui957msmo6en; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX idx77ceolnf7rok8ui957msmo6en ON public."BillingEvent" USING btree (domain_repo_id, domain_history_revision_id);
--
-- Name: idx7v75e535c47mxfb2rk9o843bn; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX idx7v75e535c47mxfb2rk9o843bn ON public."BillingCancellation" USING btree (domain_repo_id, domain_history_revision_id);
--
-- Name: idx8gtvnbk64yskcvrdp61f5ied3; Type: INDEX; Schema: public; Owner: -
--
@@ -2121,6 +2142,13 @@ CREATE INDEX idxd01j17vrpjxaerxdmn8bwxs7s ON public."GracePeriodHistory" USING b
CREATE INDEX idxe7wu46c7wpvfmfnj4565abibp ON public."PollMessage" USING btree (registrar_id);
--
-- Name: idxehp8ejwpbsooar0e8k32847m3; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX idxehp8ejwpbsooar0e8k32847m3 ON public."BillingEvent" USING btree (domain_repo_id, recurrence_history_revision_id);
--
-- Name: idxeokttmxtpq2hohcioe5t2242b; Type: INDEX; Schema: public; Owner: -
--
@@ -2261,6 +2289,13 @@ CREATE INDEX idxku0fopwyvd57ebo8bf0jg9xo2 ON public."BillingCancellation" USING
CREATE INDEX idxl49vydnq0h5j1piefwjy4i8er ON public."Host" USING btree (current_sponsor_registrar_id);
--
-- Name: idxl67y6wclc2uaupepnvkoo81fl; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX idxl67y6wclc2uaupepnvkoo81fl ON public."GracePeriodHistory" USING btree (domain_repo_id, domain_history_revision_id);
--
-- Name: idxl8vobbecsd32k4ksavdfx8st6; Type: INDEX; Schema: public; Owner: -
--
@@ -2275,6 +2310,13 @@ CREATE INDEX idxl8vobbecsd32k4ksavdfx8st6 ON public."BillingCancellation" USING
CREATE INDEX idxlg6a5tp70nch9cp0gc11brc5o ON public."PackagePromotion" USING btree (token);
--
-- Name: idxlh9lvmxb2dj3ti83buauwvbil; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX idxlh9lvmxb2dj3ti83buauwvbil ON public."BillingRecurrence" USING btree (domain_repo_id, domain_history_revision_id);
--
-- Name: idxlrq7v63pc21uoh3auq6eybyhl; Type: INDEX; Schema: public; Owner: -
--
@@ -2289,6 +2331,13 @@ CREATE INDEX idxlrq7v63pc21uoh3auq6eybyhl ON public."Domain" USING btree (autore
CREATE INDEX idxm6k18dusy2lfi5y81k8g256sa ON public."RegistrarUpdateHistory" USING btree (history_acting_user);
--
-- Name: idxmk1d2ngdtfkg6odmw7l5ejisw; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX idxmk1d2ngdtfkg6odmw7l5ejisw ON public."DomainDsDataHistory" USING btree (domain_repo_id, domain_history_revision_id);
--
-- Name: idxn1f711wicdnooa2mqb7g1m55o; Type: INDEX; Schema: public; Owner: -
--
@@ -2317,6 +2366,13 @@ CREATE INDEX idxnb02m43jcx24r64n8rbg22u4q ON public."Domain" USING btree (admin_
CREATE INDEX idxnjhib7v6fj7dhj5qydkefkl2u ON public."Domain" USING btree (lordn_phase) WHERE (lordn_phase <> 'NONE'::text);
--
-- Name: idxnuyqo6hrtuvbcmuecf7vkfmle; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX idxnuyqo6hrtuvbcmuecf7vkfmle ON public."PollMessage" USING btree (domain_repo_id, domain_history_revision_id);
--
-- Name: idxo1xdtpij2yryh0skxe9v91sep; Type: INDEX; Schema: public; Owner: -
--
@@ -2569,14 +2625,6 @@ ALTER TABLE ONLY public."ClaimsEntry"
ADD CONSTRAINT fk6sc6at5hedffc0nhdcab6ivuq FOREIGN KEY (revision_id) REFERENCES public."ClaimsList"(revision_id) DEFERRABLE INITIALLY DEFERRED;
--
-- Name: GracePeriodHistory fk7w3cx8d55q8bln80e716tr7b8; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public."GracePeriodHistory"
ADD CONSTRAINT fk7w3cx8d55q8bln80e716tr7b8 FOREIGN KEY (domain_repo_id, domain_history_revision_id) REFERENCES public."DomainHistory"(domain_repo_id, history_revision_id) DEFERRABLE INITIALLY DEFERRED;
--
-- Name: Contact fk93c185fx7chn68uv7nl6uv2s0; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@@ -2601,14 +2649,6 @@ ALTER TABLE ONLY public."BillingCancellation"
ADD CONSTRAINT fk_billing_cancellation_billing_recurrence_id FOREIGN KEY (billing_recurrence_id) REFERENCES public."BillingRecurrence"(billing_recurrence_id) DEFERRABLE INITIALLY DEFERRED;
--
-- Name: BillingCancellation fk_billing_cancellation_domain_history; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public."BillingCancellation"
ADD CONSTRAINT fk_billing_cancellation_domain_history FOREIGN KEY (domain_repo_id, domain_history_revision_id) REFERENCES public."DomainHistory"(domain_repo_id, history_revision_id) DEFERRABLE INITIALLY DEFERRED;
--
-- Name: BillingCancellation fk_billing_cancellation_registrar_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@@ -2633,22 +2673,6 @@ ALTER TABLE ONLY public."BillingEvent"
ADD CONSTRAINT fk_billing_event_cancellation_matching_billing_recurrence_id FOREIGN KEY (cancellation_matching_billing_recurrence_id) REFERENCES public."BillingRecurrence"(billing_recurrence_id) DEFERRABLE INITIALLY DEFERRED;
--
-- Name: BillingEvent fk_billing_event_domain_history; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public."BillingEvent"
ADD CONSTRAINT fk_billing_event_domain_history FOREIGN KEY (domain_repo_id, domain_history_revision_id) REFERENCES public."DomainHistory"(domain_repo_id, history_revision_id) DEFERRABLE INITIALLY DEFERRED;
--
-- Name: BillingEvent fk_billing_event_recurrence_history; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public."BillingEvent"
ADD CONSTRAINT fk_billing_event_recurrence_history FOREIGN KEY (domain_repo_id, recurrence_history_revision_id) REFERENCES public."DomainHistory"(domain_repo_id, history_revision_id) DEFERRABLE INITIALLY DEFERRED;
--
-- Name: BillingEvent fk_billing_event_registrar_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@@ -2657,14 +2681,6 @@ ALTER TABLE ONLY public."BillingEvent"
ADD CONSTRAINT fk_billing_event_registrar_id FOREIGN KEY (registrar_id) REFERENCES public."Registrar"(registrar_id) DEFERRABLE INITIALLY DEFERRED;
--
-- Name: BillingRecurrence fk_billing_recurrence_domain_history; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public."BillingRecurrence"
ADD CONSTRAINT fk_billing_recurrence_domain_history FOREIGN KEY (domain_repo_id, domain_history_revision_id) REFERENCES public."DomainHistory"(domain_repo_id, history_revision_id) DEFERRABLE INITIALLY DEFERRED;
--
-- Name: BillingRecurrence fk_billing_recurrence_registrar_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@@ -2937,14 +2953,6 @@ ALTER TABLE ONLY public."PollMessage"
ADD CONSTRAINT fk_poll_message_contact_repo_id FOREIGN KEY (contact_repo_id) REFERENCES public."Contact"(repo_id) DEFERRABLE INITIALLY DEFERRED;
--
-- Name: PollMessage fk_poll_message_domain_history; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public."PollMessage"
ADD CONSTRAINT fk_poll_message_domain_history FOREIGN KEY (domain_repo_id, domain_history_revision_id) REFERENCES public."DomainHistory"(domain_repo_id, history_revision_id) DEFERRABLE INITIALLY DEFERRED;
--
-- Name: PollMessage fk_poll_message_domain_repo_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@@ -3025,14 +3033,6 @@ ALTER TABLE ONLY public."BsaUnblockableDomain"
ADD CONSTRAINT fkbsaunblockabledomainlabel FOREIGN KEY (label) REFERENCES public."BsaLabel"(label) ON DELETE CASCADE;
--
-- Name: DomainTransactionRecord fkcjqe54u72kha71vkibvxhjye7; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public."DomainTransactionRecord"
ADD CONSTRAINT fkcjqe54u72kha71vkibvxhjye7 FOREIGN KEY (domain_repo_id, history_revision_id) REFERENCES public."DomainHistory"(domain_repo_id, history_revision_id) DEFERRABLE INITIALLY DEFERRED;
--
-- Name: DomainHost fkfmi7bdink53swivs390m2btxg; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@@ -3081,14 +3081,6 @@ ALTER TABLE ONLY public."PremiumEntry"
ADD CONSTRAINT fko0gw90lpo1tuee56l0nb6y6g5 FOREIGN KEY (revision_id) REFERENCES public."PremiumList"(revision_id) DEFERRABLE INITIALLY DEFERRED;
--
-- Name: DomainDsDataHistory fko4ilgyyfnvppbpuivus565i0j; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public."DomainDsDataHistory"
ADD CONSTRAINT fko4ilgyyfnvppbpuivus565i0j FOREIGN KEY (domain_repo_id, domain_history_revision_id) REFERENCES public."DomainHistory"(domain_repo_id, history_revision_id) DEFERRABLE INITIALLY DEFERRED;
--
-- Name: RegistrarPocUpdateHistory fkregistrarpocupdatehistoryemailaddress; Type: FK CONSTRAINT; Schema: public; Owner: -
--