Commit 00997da2 authored by Alper Akgun's avatar Alper Akgun

Optimizes the ci_pipelines counter query

Adds an index for batch counting in usage data
parent 533c399f
---
title: Optimize ci_pipelines counters in usage data
merge_request: 26774
author:
type: performance
# frozen_string_literal: true
class AddIndexOnUserIdAndCreatedAtToCiPipelines < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :ci_pipelines, [:user_id, :created_at]
remove_concurrent_index :ci_pipelines, [:user_id]
end
def down
add_concurrent_index :ci_pipelines, [:user_id]
remove_concurrent_index :ci_pipelines, [:user_id, :created_at]
end
end
......@@ -873,7 +873,7 @@ ActiveRecord::Schema.define(version: 2020_03_06_170531) do
t.index ["project_id", "status", "config_source"], name: "index_ci_pipelines_on_project_id_and_status_and_config_source"
t.index ["project_id", "status", "updated_at"], name: "index_ci_pipelines_on_project_id_and_status_and_updated_at"
t.index ["status"], name: "index_ci_pipelines_on_status"
t.index ["user_id"], name: "index_ci_pipelines_on_user_id"
t.index ["user_id", "created_at"], name: "index_ci_pipelines_on_user_id_and_created_at"
end
create_table "ci_pipelines_config", primary_key: "pipeline_id", force: :cascade do |t|
......
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