mirror of
https://github.com/google/nomulus
synced 2026-09-07 00:27:03 +00:00
Add hash indexes for common use cases (#2834)
I went through all the SQL statements generated by some sample DomainCreateFlow and DomainDeleteFlow cases to find situations where we were either SELECTing from, or UPDATEing, tables with a direct "field = value" format. These are the situations that I found where we can add hash indexes. This does two things: 1. Makes these queries slight faster, since these are usually queries on columns that are either unique or very close to unique, and O(1) is faster than O(log(n)) 2. Spreads around the optimistic predicate locks on the previously-used btree indexes. Many of our serialization errors came from the fact that we were autogenerating incrementing ID values for various tables, meaning that SELECTs, INSERTs, and UPDATEs would all try to take predicate locks out on the same page of the btree index. Using a hash index means that the page locks will be spread out to various index pages, rather than conflicting with each other. Running load tests on alpha I see significant improvements in speed and error rates. Speed is hard to quantify due to the nature of the way the load tests distribute tasks among the queues but it could be more than 50% improvement, and serialization errors in the logs drop by more than 90%.
This commit is contained in:
@@ -1924,6 +1924,48 @@ ALTER TABLE ONLY public."User"
|
||||
CREATE INDEX allocation_token_domain_name_idx ON public."AllocationToken" USING btree (domain_name);
|
||||
|
||||
|
||||
--
|
||||
-- Name: billingcancellation_billing_cancellation_id_hash; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX billingcancellation_billing_cancellation_id_hash ON public."BillingCancellation" USING hash (billing_cancellation_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: billingevent_billing_event_id_hash; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX billingevent_billing_event_id_hash ON public."BillingEvent" USING hash (billing_event_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: billingrecurrence_billing_recurrence_id_hash; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX billingrecurrence_billing_recurrence_id_hash ON public."BillingRecurrence" USING hash (billing_recurrence_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: delegationsignerdata_domain_repo_id_hash; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX delegationsignerdata_domain_repo_id_hash ON public."DelegationSignerData" USING hash (domain_repo_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: domain_domain_name_hash; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX domain_domain_name_hash ON public."Domain" USING hash (domain_name);
|
||||
|
||||
|
||||
--
|
||||
-- Name: domain_domain_repo_id_hash; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX domain_domain_repo_id_hash ON public."Domain" USING hash (repo_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: domain_history_to_ds_data_history_idx; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
@@ -1938,6 +1980,76 @@ 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: domainhistory_domain_repo_id_hash; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX domainhistory_domain_repo_id_hash ON public."DomainHistory" USING hash (domain_repo_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: domainhistory_history_revision_id_hash; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX domainhistory_history_revision_id_hash ON public."DomainHistory" USING hash (history_revision_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: domainhost_domain_repo_id_hash; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX domainhost_domain_repo_id_hash ON public."DomainHost" USING hash (domain_repo_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: domaintransactionrecord_domain_history_revision_id_hash; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX domaintransactionrecord_domain_history_revision_id_hash ON public."DomainTransactionRecord" USING hash (history_revision_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: domaintransactionrecord_id_hash; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX domaintransactionrecord_id_hash ON public."DomainTransactionRecord" USING hash (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: graceperiod_domain_repo_id_hash; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX graceperiod_domain_repo_id_hash ON public."GracePeriod" USING hash (domain_repo_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: graceperiod_grace_period_id_hash; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX graceperiod_grace_period_id_hash ON public."GracePeriod" USING hash (grace_period_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: graceperiodhistory_grace_period_history_revision_id_hash; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX graceperiodhistory_grace_period_history_revision_id_hash ON public."GracePeriodHistory" USING hash (grace_period_history_revision_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: host_host_name_hash; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX host_host_name_hash ON public."Host" USING hash (host_name);
|
||||
|
||||
|
||||
--
|
||||
-- Name: host_repo_id_hash; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX host_repo_id_hash ON public."Host" USING hash (repo_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: idx1dyqmqb61xbnj7mt7bk27ds25; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
@@ -2617,6 +2729,13 @@ CREATE INDEX idxtmlqd31dpvvd2g1h9i7erw6aj ON public."AllocationToken" USING btre
|
||||
CREATE INDEX idxy98mebut8ix1v07fjxxdkqcx ON public."Host" USING btree (creation_time);
|
||||
|
||||
|
||||
--
|
||||
-- Name: pollmessage_poll_message_id_hash; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX pollmessage_poll_message_id_hash ON public."PollMessage" USING hash (poll_message_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: premiumlist_name_idx; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user