2020-09-25 15:09:36 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Database
|
|
|
|
module Reindexing
|
2020-12-10 12:09:43 +00:00
|
|
|
# Number of indexes to reindex per invocation
|
|
|
|
DEFAULT_INDEXES_PER_INVOCATION = 2
|
|
|
|
|
|
|
|
# candidate_indexes: Array of Gitlab::Database::PostgresIndex
|
|
|
|
def self.perform(candidate_indexes, how_many: DEFAULT_INDEXES_PER_INVOCATION)
|
2020-12-31 09:10:34 +00:00
|
|
|
IndexSelection.new(candidate_indexes).take(how_many).each do |index|
|
|
|
|
Coordinator.new(index).perform
|
|
|
|
end
|
2020-09-25 15:09:36 +00:00
|
|
|
end
|
2020-10-01 18:10:20 +00:00
|
|
|
|
|
|
|
def self.candidate_indexes
|
|
|
|
Gitlab::Database::PostgresIndex
|
|
|
|
.regular
|
2020-11-11 00:08:58 +00:00
|
|
|
.where('NOT expression')
|
2020-10-01 18:10:20 +00:00
|
|
|
.not_match("^#{ConcurrentReindex::TEMPORARY_INDEX_PREFIX}")
|
|
|
|
.not_match("^#{ConcurrentReindex::REPLACED_INDEX_PREFIX}")
|
|
|
|
end
|
2020-09-25 15:09:36 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|