Add 9 more indexes to SQL schema (#1540)

These indexes were identified as missing by PostgreSQL's query analyzer in our
sandbox environment (where we get enough realistic EPP traffic to identify these
deficiencies).

Note that a lot of the new indexes being named have to use the DB representation
of the column name because they are either embedded or subclassed entities,
whereas most of the existing ones are able to simply refer to Java field names.

This is the Java schema follow-up PR to PR #1541, which is what added the
actual DB changes through Flyway scripts.
This commit is contained in:
Ben McIlwain 2022-03-14 15:59:05 -04:00 committed by GitHub
parent f674f2a351
commit 2e9aa8db2d
7 changed files with 37 additions and 16 deletions

View file

@ -308,7 +308,8 @@ public abstract class BillingEvent extends ImmutableObject
@javax.persistence.Index(columnList = "eventTime"), @javax.persistence.Index(columnList = "eventTime"),
@javax.persistence.Index(columnList = "billingTime"), @javax.persistence.Index(columnList = "billingTime"),
@javax.persistence.Index(columnList = "syntheticCreationTime"), @javax.persistence.Index(columnList = "syntheticCreationTime"),
@javax.persistence.Index(columnList = "allocationToken") @javax.persistence.Index(columnList = "allocationToken"),
@javax.persistence.Index(columnList = "cancellation_matching_billing_recurrence_id")
}) })
@AttributeOverride(name = "id", column = @Column(name = "billing_event_id")) @AttributeOverride(name = "id", column = @Column(name = "billing_event_id"))
@WithLongVKey(compositeKey = true) @WithLongVKey(compositeKey = true)
@ -614,7 +615,9 @@ public abstract class BillingEvent extends ImmutableObject
indexes = { indexes = {
@javax.persistence.Index(columnList = "registrarId"), @javax.persistence.Index(columnList = "registrarId"),
@javax.persistence.Index(columnList = "eventTime"), @javax.persistence.Index(columnList = "eventTime"),
@javax.persistence.Index(columnList = "billingTime") @javax.persistence.Index(columnList = "billingTime"),
@javax.persistence.Index(columnList = "billing_event_id"),
@javax.persistence.Index(columnList = "billing_recurrence_id")
}) })
@AttributeOverride(name = "id", column = @Column(name = "billing_cancellation_id")) @AttributeOverride(name = "id", column = @Column(name = "billing_cancellation_id"))
@WithLongVKey(compositeKey = true) @WithLongVKey(compositeKey = true)

View file

@ -69,7 +69,10 @@ import org.joda.time.DateTime;
@Index(columnList = "techContact"), @Index(columnList = "techContact"),
@Index(columnList = "tld"), @Index(columnList = "tld"),
@Index(columnList = "registrantContact"), @Index(columnList = "registrantContact"),
@Index(columnList = "dnsRefreshRequestTime") @Index(columnList = "dnsRefreshRequestTime"),
@Index(columnList = "billing_recurrence_id"),
@Index(columnList = "transfer_billing_event_id"),
@Index(columnList = "transfer_billing_recurrence_id")
}) })
@WithStringVKey @WithStringVKey
@ExternalMessagingName("domain") @ExternalMessagingName("domain")
@ -89,7 +92,10 @@ public class DomainBase extends DomainContent
@ElementCollection @ElementCollection
@JoinTable( @JoinTable(
name = "DomainHost", name = "DomainHost",
indexes = {@Index(columnList = "domain_repo_id,host_repo_id", unique = true)}) indexes = {
@Index(columnList = "domain_repo_id,host_repo_id", unique = true),
@Index(columnList = "host_repo_id")
})
@Access(AccessType.PROPERTY) @Access(AccessType.PROPERTY)
@Column(name = "host_repo_id") @Column(name = "host_repo_id")
public Set<VKey<HostResource>> getNsHosts() { public Set<VKey<HostResource>> getNsHosts() {

View file

@ -46,7 +46,12 @@ import org.joda.time.DateTime;
*/ */
@Embed @Embed
@Entity @Entity
@Table(indexes = @Index(columnList = "domainRepoId")) @Table(
indexes = {
@Index(columnList = "domainRepoId"),
@Index(columnList = "billing_event_id"),
@Index(columnList = "billing_recurrence_id")
})
public class GracePeriod extends GracePeriodBase implements DatastoreAndSqlEntity { public class GracePeriod extends GracePeriodBase implements DatastoreAndSqlEntity {
@Id @Id

View file

@ -94,8 +94,6 @@ public class DomainTransferData extends TransferData<DomainTransferData.Builder>
* *
* <p>This field should be null if there is not currently a pending transfer or if the object * <p>This field should be null if there is not currently a pending transfer or if the object
* being transferred is not a domain. * being transferred is not a domain.
*
* <p>TODO(b/158230654) Remove unused columns for TransferData in Contact table.
*/ */
@IgnoreSave(IfNull.class) @IgnoreSave(IfNull.class)
@Column(name = "transfer_billing_event_id") @Column(name = "transfer_billing_event_id")

View file

@ -261,7 +261,7 @@ td.section {
</tr> </tr>
<tr> <tr>
<td class="property_name">generated on</td> <td class="property_name">generated on</td>
<td class="property_value">2022-03-09 22:28:58.465478</td> <td class="property_value">2022-03-14 17:59:45.688046</td>
</tr> </tr>
<tr> <tr>
<td class="property_name">last flyway file</td> <td class="property_name">last flyway file</td>
@ -284,7 +284,7 @@ td.section {
generated on generated on
</text> </text>
<text text-anchor="start" x="4055.5" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="4055.5" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">
2022-03-09 22:28:58.465478 2022-03-14 17:59:45.688046
</text> </text>
<polygon fill="none" stroke="#888888" points="3968,-4 3968,-44 4233,-44 4233,-4 3968,-4" /> <!-- allocationtoken_a08ccbef --> <polygon fill="none" stroke="#888888" points="3968,-4 3968,-44 4233,-44 4233,-4 3968,-4" /> <!-- allocationtoken_a08ccbef -->
<g id="node1" class="node"> <g id="node1" class="node">

View file

@ -261,7 +261,7 @@ td.section {
</tr> </tr>
<tr> <tr>
<td class="property_name">generated on</td> <td class="property_name">generated on</td>
<td class="property_value">2022-03-09 22:28:56.561494</td> <td class="property_value">2022-03-14 17:59:44.31197</td>
</tr> </tr>
<tr> <tr>
<td class="property_name">last flyway file</td> <td class="property_name">last flyway file</td>
@ -274,19 +274,19 @@ td.section {
<svg viewbox="0.00 0.00 4949.02 4890.50" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="erDiagram" style="overflow: hidden; width: 100%; height: 800px"> <g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 4886.5)"> <svg viewbox="0.00 0.00 4949.02 4890.50" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="erDiagram" style="overflow: hidden; width: 100%; height: 800px"> <g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 4886.5)">
<title>SchemaCrawler_Diagram</title> <title>SchemaCrawler_Diagram</title>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-4886.5 4945.02,-4886.5 4945.02,4 -4,4" /> <polygon fill="white" stroke="transparent" points="-4,4 -4,-4886.5 4945.02,-4886.5 4945.02,4 -4,4" />
<text text-anchor="start" x="4672.52" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="4680.52" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">
generated by generated by
</text> </text>
<text text-anchor="start" x="4755.52" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="4763.52" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">
SchemaCrawler 16.10.1 SchemaCrawler 16.10.1
</text> </text>
<text text-anchor="start" x="4671.52" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="4679.52" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">
generated on generated on
</text> </text>
<text text-anchor="start" x="4755.52" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="4763.52" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">
2022-03-09 22:28:56.561494 2022-03-14 17:59:44.31197
</text> </text>
<polygon fill="none" stroke="#888888" points="4668.02,-4 4668.02,-44 4933.02,-44 4933.02,-4 4668.02,-4" /> <!-- allocationtoken_a08ccbef --> <polygon fill="none" stroke="#888888" points="4676.02,-4 4676.02,-44 4933.02,-44 4933.02,-4 4676.02,-4" /> <!-- allocationtoken_a08ccbef -->
<g id="node1" class="node"> <g id="node1" class="node">
<title>allocationtoken_a08ccbef</title> <title>allocationtoken_a08ccbef</title>
<polygon fill="#ebcef2" stroke="transparent" points="3100.5,-651.5 3100.5,-670.5 3299.5,-670.5 3299.5,-651.5 3100.5,-651.5" /> <polygon fill="#ebcef2" stroke="transparent" points="3100.5,-651.5 3100.5,-670.5 3299.5,-670.5 3299.5,-651.5 3100.5,-651.5" />

View file

@ -762,11 +762,14 @@ create index allocation_token_domain_name_idx on "AllocationToken" (domain_name)
create index IDXih4b2tea127p5rb61gje6e1y2 on "BillingCancellation" (registrar_id); create index IDXih4b2tea127p5rb61gje6e1y2 on "BillingCancellation" (registrar_id);
create index IDX2exdfbx6oiiwnhr8j6gjpqt2j on "BillingCancellation" (event_time); create index IDX2exdfbx6oiiwnhr8j6gjpqt2j on "BillingCancellation" (event_time);
create index IDXqa3g92jc17e8dtiaviy4fet4x on "BillingCancellation" (billing_time); create index IDXqa3g92jc17e8dtiaviy4fet4x on "BillingCancellation" (billing_time);
create index IDX4ytbe5f3b39trsd4okx5ijhs4 on "BillingCancellation" (billing_event_id);
create index IDXku0fopwyvd57ebo8bf0jg9xo2 on "BillingCancellation" (billing_recurrence_id);
create index IDXqspv57gj2led8ly42fq01t7m7 on "BillingEvent" (registrar_id); create index IDXqspv57gj2led8ly42fq01t7m7 on "BillingEvent" (registrar_id);
create index IDX5yfbr88439pxw0v3j86c74fp8 on "BillingEvent" (event_time); create index IDX5yfbr88439pxw0v3j86c74fp8 on "BillingEvent" (event_time);
create index IDX6py6ocrab0ivr76srcd2okpnq on "BillingEvent" (billing_time); create index IDX6py6ocrab0ivr76srcd2okpnq on "BillingEvent" (billing_time);
create index IDXplxf9v56p0wg8ws6qsvd082hk on "BillingEvent" (synthetic_creation_time); create index IDXplxf9v56p0wg8ws6qsvd082hk on "BillingEvent" (synthetic_creation_time);
create index IDXcesda59ssop44kklytpb292hn on "BillingEvent" (allocation_token); create index IDXcesda59ssop44kklytpb292hn on "BillingEvent" (allocation_token);
create index IDX6ebt3nwk5ocvnremnhnlkl6ff on "BillingEvent" (cancellation_matching_billing_recurrence_id);
create index IDXd3gxhkh0jk694pjvh9pyn7wjc on "BillingRecurrence" (registrar_id); create index IDXd3gxhkh0jk694pjvh9pyn7wjc on "BillingRecurrence" (registrar_id);
create index IDX6syykou4nkc7hqa5p8r92cpch on "BillingRecurrence" (event_time); create index IDX6syykou4nkc7hqa5p8r92cpch on "BillingRecurrence" (event_time);
create index IDXp3usbtvk0v1m14i5tdp4xnxgc on "BillingRecurrence" (recurrence_end_time); create index IDXp3usbtvk0v1m14i5tdp4xnxgc on "BillingRecurrence" (recurrence_end_time);
@ -792,6 +795,9 @@ create index IDXr22ciyccwi9rrqmt1ro0s59qf on "Domain" (tech_contact);
create index IDXrwl38wwkli1j7gkvtywi9jokq on "Domain" (tld); create index IDXrwl38wwkli1j7gkvtywi9jokq on "Domain" (tld);
create index IDXa7fu0bqynfb79rr80528b4jqt on "Domain" (registrant_contact); create index IDXa7fu0bqynfb79rr80528b4jqt on "Domain" (registrant_contact);
create index IDXcws5mvmpl8o10wrhde780ors2 on "Domain" (dns_refresh_request_time); create index IDXcws5mvmpl8o10wrhde780ors2 on "Domain" (dns_refresh_request_time);
create index IDXsfci08jgsymxy6ovh4k7r358c on "Domain" (billing_recurrence_id);
create index IDX3y3k7m2bkgahm9sixiohgyrga on "Domain" (transfer_billing_event_id);
create index IDXcju58vqascbpve1t7fem53ctl on "Domain" (transfer_billing_recurrence_id);
create index IDXrh4xmrot9bd63o382ow9ltfig on "DomainHistory" (creation_time); create index IDXrh4xmrot9bd63o382ow9ltfig on "DomainHistory" (creation_time);
create index IDXaro1omfuaxjwmotk3vo00trwm on "DomainHistory" (history_registrar_id); create index IDXaro1omfuaxjwmotk3vo00trwm on "DomainHistory" (history_registrar_id);
create index IDXsu1nam10cjes9keobapn5jvxj on "DomainHistory" (history_type); create index IDXsu1nam10cjes9keobapn5jvxj on "DomainHistory" (history_type);
@ -799,10 +805,13 @@ create index IDX6w3qbtgce93cal2orjg1tw7b7 on "DomainHistory" (history_modificati
alter table if exists "DomainHistoryHost" alter table if exists "DomainHistoryHost"
add constraint UKt2e7ae3t8gcsxd13wjx2ka7ij unique (domain_history_history_revision_id, domain_history_domain_repo_id, host_repo_id); add constraint UKt2e7ae3t8gcsxd13wjx2ka7ij unique (domain_history_history_revision_id, domain_history_domain_repo_id, host_repo_id);
create index IDXjw3rwtfrexyq53x9vu7qghrdt on "DomainHost" (host_repo_id);
alter table if exists "DomainHost" alter table if exists "DomainHost"
add constraint UKat9erbh52e4lg3jw6ai9wkjj9 unique (domain_repo_id, host_repo_id); add constraint UKat9erbh52e4lg3jw6ai9wkjj9 unique (domain_repo_id, host_repo_id);
create index IDXj1mtx98ndgbtb1bkekahms18w on "GracePeriod" (domain_repo_id); create index IDXj1mtx98ndgbtb1bkekahms18w on "GracePeriod" (domain_repo_id);
create index IDXbgssjudpm428mrv0xfpvgifps on "GracePeriod" (billing_event_id);
create index IDX5u5m6clpk3nktrvtyy5umacb6 on "GracePeriod" (billing_recurrence_id);
create index IDXd01j17vrpjxaerxdmn8bwxs7s on "GracePeriodHistory" (domain_repo_id); create index IDXd01j17vrpjxaerxdmn8bwxs7s on "GracePeriodHistory" (domain_repo_id);
create index IDXkpkh68n6dy5v51047yr6b0e9l on "Host" (host_name); create index IDXkpkh68n6dy5v51047yr6b0e9l on "Host" (host_name);
create index IDXfg2nnjlujxo6cb9fha971bq2n on "HostHistory" (creation_time); create index IDXfg2nnjlujxo6cb9fha971bq2n on "HostHistory" (creation_time);