summaryrefslogtreecommitdiff
path: root/lib/gitlab/database/async_indexes.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/database/async_indexes.rb')
-rw-r--r--lib/gitlab/database/async_indexes.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/gitlab/database/async_indexes.rb b/lib/gitlab/database/async_indexes.rb
new file mode 100644
index 00000000000..d89d5238356
--- /dev/null
+++ b/lib/gitlab/database/async_indexes.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module Database
+ module AsyncIndexes
+ DEFAULT_INDEXES_PER_INVOCATION = 2
+
+ def self.create_pending_indexes!(how_many: DEFAULT_INDEXES_PER_INVOCATION)
+ PostgresAsyncIndex.order(:id).limit(how_many).each do |async_index|
+ IndexCreator.new(async_index).perform
+ end
+ end
+ end
+ end
+end