Migration for indexes on containers and container_requests.
authorPeter Amstutz <pamstutz@veritasgenetics.com>
Fri, 27 Oct 2017 18:42:03 +0000 (14:42 -0400)
committerPeter Amstutz <pamstutz@veritasgenetics.com>
Fri, 27 Oct 2017 18:46:43 +0000 (14:46 -0400)
refs #12500

Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz@veritasgenetics.com>

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

diff --git a/services/api/db/migrate/20171027183824_add_index_to_containers.rb b/services/api/db/migrate/20171027183824_add_index_to_containers.rb
new file mode 100644 (file)
index 0000000..d90011c
--- /dev/null
@@ -0,0 +1,11 @@
+class AddIndexToContainers < ActiveRecord::Migration
+  def up
+    ActiveRecord::Base.connection.execute("CREATE INDEX index_containers_on_modified_at_uuid ON containers USING btree (modified_at desc, uuid asc)")
+    ActiveRecord::Base.connection.execute("CREATE INDEX index_container_requests_on_container_uuid on container_requests (container_uuid)")
+  end
+
+  def down
+    ActiveRecord::Base.connection.execute("DROP INDEX IF EXISTS index_containers_on_modified_at_uuid")
+    ActiveRecord::Base.connection.execute("DROP INDEX IF EXISTS index_container_requests_on_container_uuid")
+  end
+end
index 2d078f3b7c948967afad89ea7833567ab03046c6..e062d43e4b30518d5f00d9846394f481a9306bab 100644 (file)
@@ -1827,6 +1827,13 @@ CREATE UNIQUE INDEX index_commit_ancestors_on_descendant_and_ancestor ON commit_
 CREATE UNIQUE INDEX index_commits_on_repository_name_and_sha1 ON commits USING btree (repository_name, sha1);
 
 
+--
+-- Name: index_container_requests_on_container_uuid; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_container_requests_on_container_uuid ON container_requests USING btree (container_uuid);
+
+
 --
 -- Name: index_container_requests_on_modified_at_uuid; Type: INDEX; Schema: public; Owner: -
 --
@@ -1855,6 +1862,13 @@ CREATE INDEX index_container_requests_on_requesting_container_uuid ON container_
 CREATE UNIQUE INDEX index_container_requests_on_uuid ON container_requests USING btree (uuid);
 
 
+--
+-- Name: index_containers_on_modified_at_uuid; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_containers_on_modified_at_uuid ON containers USING btree (modified_at DESC, uuid);
+
+
 --
 -- Name: index_containers_on_owner_uuid; Type: INDEX; Schema: public; Owner: -
 --
@@ -3016,3 +3030,5 @@ INSERT INTO schema_migrations (version) VALUES ('20170824202826');
 
 INSERT INTO schema_migrations (version) VALUES ('20170906224040');
 
+INSERT INTO schema_migrations (version) VALUES ('20171027183824');
+