13924: Add index for PDH lookups.
authorTom Clegg <tclegg@veritasgenetics.com>
Mon, 20 Aug 2018 13:17:26 +0000 (09:17 -0400)
committerTom Clegg <tclegg@veritasgenetics.com>
Mon, 20 Aug 2018 14:03:12 +0000 (10:03 -0400)
Commit 2ee4ee2bb666835c41019b475dd2e286604bdd35 changed PDH lookup
queries to sort on trash_at, which can be slow without an index.

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>

services/api/db/migrate/20180820130357_add_pdh_and_trash_index_to_collections.rb [new file with mode: 0644]
services/api/db/structure.sql

diff --git a/services/api/db/migrate/20180820130357_add_pdh_and_trash_index_to_collections.rb b/services/api/db/migrate/20180820130357_add_pdh_and_trash_index_to_collections.rb
new file mode 100644 (file)
index 0000000..8d1cdf3
--- /dev/null
@@ -0,0 +1,9 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
+class AddPdhAndTrashIndexToCollections < ActiveRecord::Migration
+  def change
+    add_index :collections, [:portable_data_hash, :trash_at]
+  end
+end
index 12158e51b4568517a73b3d11abec97eada45d527..d2187514a30e3419747fad9135990208bbf4f73a 100644 (file)
@@ -1829,6 +1829,13 @@ CREATE UNIQUE INDEX index_collections_on_owner_uuid_and_name ON public.collectio
 CREATE INDEX index_collections_on_portable_data_hash ON public.collections USING btree (portable_data_hash);
 
 
+--
+-- Name: index_collections_on_portable_data_hash_and_trash_at; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_collections_on_portable_data_hash_and_trash_at ON public.collections USING btree (portable_data_hash, trash_at);
+
+
 --
 -- Name: index_collections_on_trash_at; Type: INDEX; Schema: public; Owner: -
 --
@@ -3121,3 +3128,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180608123145');
 
 INSERT INTO schema_migrations (version) VALUES ('20180806133039');
 
+INSERT INTO schema_migrations (version) VALUES ('20180820130357');
+