14008: Merge branch 'master' into 14008-containers-index
authorTom Clegg <tclegg@veritasgenetics.com>
Tue, 4 Sep 2018 19:03:58 +0000 (15:03 -0400)
committerTom Clegg <tclegg@veritasgenetics.com>
Tue, 4 Sep 2018 19:03:58 +0000 (15:03 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>

services/api/db/migrate/20180820132617_add_lock_index_to_containers.rb [new file with mode: 0644]
services/api/db/migrate/20180824155207_add_queue_index_to_containers.rb [new file with mode: 0644]
services/api/db/structure.sql

diff --git a/services/api/db/migrate/20180820132617_add_lock_index_to_containers.rb b/services/api/db/migrate/20180820132617_add_lock_index_to_containers.rb
new file mode 100644 (file)
index 0000000..94ca100
--- /dev/null
@@ -0,0 +1,13 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
+class AddLockIndexToContainers < ActiveRecord::Migration
+  def change
+    # For the current code in sdk/go/dispatch:
+    add_index :containers, [:locked_by_uuid, :priority]
+    # For future dispatchers that use filters instead of offset for
+    # more predictable paging:
+    add_index :containers, [:locked_by_uuid, :uuid]
+  end
+end
diff --git a/services/api/db/migrate/20180824155207_add_queue_index_to_containers.rb b/services/api/db/migrate/20180824155207_add_queue_index_to_containers.rb
new file mode 100644 (file)
index 0000000..7245108
--- /dev/null
@@ -0,0 +1,12 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
+class AddQueueIndexToContainers < ActiveRecord::Migration
+  def up
+    ActiveRecord::Base.connection.execute 'CREATE INDEX index_containers_on_queued_state on containers (state, (priority > 0))'
+  end
+  def down
+    ActiveRecord::Base.connection.execute 'DROP INDEX index_containers_on_queued_state'
+  end
+end
index f42dd8d7cfa94669508c907538c01a0e644b2083..32b77ed17aa0a4b511fafb50dd04c7d5f45371fa 100644 (file)
@@ -1899,6 +1899,20 @@ CREATE UNIQUE INDEX index_container_requests_on_uuid ON public.container_request
 CREATE INDEX index_containers_on_auth_uuid ON public.containers USING btree (auth_uuid);
 
 
+--
+-- Name: index_containers_on_locked_by_uuid_and_priority; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_containers_on_locked_by_uuid_and_priority ON public.containers USING btree (locked_by_uuid, priority);
+
+
+--
+-- Name: index_containers_on_locked_by_uuid_and_uuid; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_containers_on_locked_by_uuid_and_uuid ON public.containers USING btree (locked_by_uuid, uuid);
+
+
 --
 -- Name: index_containers_on_modified_at_uuid; Type: INDEX; Schema: public; Owner: -
 --
@@ -1913,6 +1927,13 @@ CREATE INDEX index_containers_on_modified_at_uuid ON public.containers USING btr
 CREATE INDEX index_containers_on_owner_uuid ON public.containers USING btree (owner_uuid);
 
 
+--
+-- Name: index_containers_on_queued_state; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_containers_on_queued_state ON public.containers USING btree (state, ((priority > 0)));
+
+
 --
 -- Name: index_containers_on_reuse_columns; Type: INDEX; Schema: public; Owner: -
 --
@@ -3130,7 +3151,11 @@ INSERT INTO schema_migrations (version) VALUES ('20180806133039');
 
 INSERT INTO schema_migrations (version) VALUES ('20180820130357');
 
+INSERT INTO schema_migrations (version) VALUES ('20180820132617');
+
 INSERT INTO schema_migrations (version) VALUES ('20180820135808');
 
 INSERT INTO schema_migrations (version) VALUES ('20180824152014');
 
+INSERT INTO schema_migrations (version) VALUES ('20180824155207');
+