From f382f63d0054557f9da628f65f2fd7ecd5ad45dd Mon Sep 17 00:00:00 2001 From: Ben McIlwain Date: Mon, 7 Mar 2022 12:21:40 -0500 Subject: [PATCH] Add domainRepoId indexes to billing events (#1545) * Add domainRepoId indexes to billing events #1544 The query analyzer identified this is a missing index on the BillingEvent table, and I added it for recurrences and cancellations as well as it's likely to be a problem for them too. "Give me all the billing events associated with a given domain by its repo ID" seems like a pretty common use case for the DB (and does appear to be used by our invoicing pipeline). This is the first of two PRs that makes just the DB changes. The second PR (#1544) will add the Java code changes, and will be committed after this one is deployed. --- .../sql/er_diagram/brief_er_diagram.html | 6 +-- .../sql/er_diagram/full_er_diagram.html | 42 +++++++++++++++++-- db/src/main/resources/sql/flyway.txt | 1 + ..._add_billingevent_domainrepoid_indexes.sql | 18 ++++++++ .../resources/sql/schema/nomulus.golden.sql | 21 ++++++++++ 5 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 db/src/main/resources/sql/flyway/V107__add_billingevent_domainrepoid_indexes.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 f91f38597..02a1121ee 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 - 2022-03-04 22:54:58.102534 + 2022-03-07 15:27:22.193205 last flyway file - V106__add_missing_indexes_from_query_analyzer.sql + V107__add_billingevent_domainrepoid_indexes.sql @@ -284,7 +284,7 @@ td.section { generated on - 2022-03-04 22:54:58.102534 + 2022-03-07 15:27:22.193205 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 d605b3cfd..2d1cd4275 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 - 2022-03-04 22:54:56.709583 + 2022-03-07 15:27:20.810747 last flyway file - V106__add_missing_indexes_from_query_analyzer.sql + V107__add_billingevent_domainrepoid_indexes.sql @@ -284,7 +284,7 @@ td.section { generated on - 2022-03-04 22:54:56.709583 + 2022-03-07 15:27:20.810747 @@ -6923,6 +6923,18 @@ td.section { + + idxl8vobbecsd32k4ksavdfx8st6 + [non-unique index] + + + + domain_repo_id + ascending + + + + idxeokttmxtpq2hohcioe5t2242b [non-unique index] @@ -7218,6 +7230,18 @@ td.section { + + idxbgfmveqa7e5hn689koikwn70r + [non-unique index] + + + + domain_repo_id + ascending + + + + idx73l103vc5900ig3p4odf0cngt [non-unique index] @@ -7454,6 +7478,18 @@ td.section { + + idxoqttafcywwdn41um6kwlt0n8b + [non-unique index] + + + + domain_repo_id + ascending + + + + idxjny8wuot75b5e6p38r47wdawu [non-unique index] diff --git a/db/src/main/resources/sql/flyway.txt b/db/src/main/resources/sql/flyway.txt index e8ada249a..846276793 100644 --- a/db/src/main/resources/sql/flyway.txt +++ b/db/src/main/resources/sql/flyway.txt @@ -104,3 +104,4 @@ V103__creation_time_not_null.sql V104__add_transfer_response_host_id_to_poll_message.sql V105__add_index_on_host_name_in_host_table.sql V106__add_missing_indexes_from_query_analyzer.sql +V107__add_billingevent_domainrepoid_indexes.sql diff --git a/db/src/main/resources/sql/flyway/V107__add_billingevent_domainrepoid_indexes.sql b/db/src/main/resources/sql/flyway/V107__add_billingevent_domainrepoid_indexes.sql new file mode 100644 index 000000000..2cd70b406 --- /dev/null +++ b/db/src/main/resources/sql/flyway/V107__add_billingevent_domainrepoid_indexes.sql @@ -0,0 +1,18 @@ +-- Copyright 2022 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 IDXbgfmveqa7e5hn689koikwn70r ON "BillingEvent" (domain_repo_id); +CREATE INDEX IDXoqttafcywwdn41um6kwlt0n8b ON "BillingRecurrence" (domain_repo_id); +CREATE INDEX IDXl8vobbecsd32k4ksavdfx8st6 ON "BillingCancellation" (domain_repo_id); diff --git a/db/src/main/resources/sql/schema/nomulus.golden.sql b/db/src/main/resources/sql/schema/nomulus.golden.sql index b00a47d93..89e3c9922 100644 --- a/db/src/main/resources/sql/schema/nomulus.golden.sql +++ b/db/src/main/resources/sql/schema/nomulus.golden.sql @@ -1665,6 +1665,13 @@ CREATE INDEX idxaro1omfuaxjwmotk3vo00trwm ON public."DomainHistory" USING btree CREATE INDEX idxaydgox62uno9qx8cjlj5lauye ON public."PollMessage" USING btree (event_time); +-- +-- Name: idxbgfmveqa7e5hn689koikwn70r; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idxbgfmveqa7e5hn689koikwn70r ON public."BillingEvent" USING btree (domain_repo_id); + + -- -- Name: idxbgssjudpm428mrv0xfpvgifps; Type: INDEX; Schema: public; Owner: - -- @@ -1791,6 +1798,13 @@ CREATE INDEX idxkpkh68n6dy5v51047yr6b0e9l ON public."Host" USING btree (host_nam CREATE INDEX idxku0fopwyvd57ebo8bf0jg9xo2 ON public."BillingCancellation" USING btree (billing_recurrence_id); +-- +-- Name: idxl8vobbecsd32k4ksavdfx8st6; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idxl8vobbecsd32k4ksavdfx8st6 ON public."BillingCancellation" USING btree (domain_repo_id); + + -- -- Name: idxlrq7v63pc21uoh3auq6eybyhl; Type: INDEX; Schema: public; Owner: - -- @@ -1833,6 +1847,13 @@ CREATE INDEX idxo1xdtpij2yryh0skxe9v91sep ON public."ContactHistory" USING btree CREATE INDEX idxoqd7n4hbx86hvlgkilq75olas ON public."Contact" USING btree (contact_id); +-- +-- Name: idxoqttafcywwdn41um6kwlt0n8b; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idxoqttafcywwdn41um6kwlt0n8b ON public."BillingRecurrence" USING btree (domain_repo_id); + + -- -- Name: idxp3usbtvk0v1m14i5tdp4xnxgc; Type: INDEX; Schema: public; Owner: - --