Commit 1f9c3955 authored by Andreas Brandl's avatar Andreas Brandl

Add index to count pending mirror updates

The index aids a rather high frequency query in
gitlab-monitor that counts pending mirror updates.
This changes brings it down from 1,500ms to <1ms.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/62419
parent 3164a4c7
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20190530154715) do
ActiveRecord::Schema.define(version: 20190603124955) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -2453,6 +2453,7 @@ ActiveRecord::Schema.define(version: 20190530154715) do
t.datetime_with_timezone "last_successful_update_at"
t.index ["jid"], name: "index_project_mirror_data_on_jid", using: :btree
t.index ["last_successful_update_at"], name: "index_project_mirror_data_on_last_successful_update_at", using: :btree
t.index ["last_update_at", "retry_count"], name: "index_project_mirror_data_on_last_update_at_and_retry_count", using: :btree
t.index ["next_execution_timestamp", "retry_count"], name: "index_mirror_data_on_next_execution_and_retry_count", using: :btree
t.index ["project_id"], name: "index_project_mirror_data_on_project_id", unique: true, using: :btree
t.index ["status"], name: "index_project_mirror_data_on_status", using: :btree
......
---
title: Add index to count pending mirror updates
merge_request: 13901
author:
type: performance
# frozen_string_literal: true
class AddIndexToCountPendingMirrorUpdates < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :project_mirror_data, [:last_update_at, :retry_count]
end
def down
remove_concurrent_index :project_mirror_data, [:last_update_at, :retry_count]
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment