Commit 60d76238 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch '208887-optimize-project-counters-mirrored-pipelines' into 'master'

Optimize mirrored project counters with pipelines enabled

See merge request gitlab-org/gitlab!26802
parents ceec9c1e bacbe1a8
---
title: Optimize Project counters with pipelines enabled counter
merge_request: 26802
author:
type: performance
# frozen_string_literal: true
class AddIndexOnProjectIdAndBuildsAccessLevelToProjectFeatures < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
INDEX_NAME = 'index_project_features_on_project_id_bal_20'
disable_ddl_transaction!
def up
add_concurrent_index :project_features, :project_id, where: 'builds_access_level = 20', name: INDEX_NAME
end
def down
remove_concurrent_index_by_name :project_features, INDEX_NAME
end
end
# frozen_string_literal: true
class AddIndexOnMirrorAndCreatorIdAndCreatedAtToProjects < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
INDEX_NAME = 'index_projects_on_mirror_creator_id_created_at'
disable_ddl_transaction!
def up
add_concurrent_index :projects, [:creator_id, :created_at], where: 'mirror = true and mirror_trigger_builds = true', name: INDEX_NAME
end
def down
remove_concurrent_index_by_name :projects, INDEX_NAME
end
end
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_03_06_170531) do ActiveRecord::Schema.define(version: 2020_03_09_195710) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm" enable_extension "pg_trgm"
...@@ -3264,6 +3264,7 @@ ActiveRecord::Schema.define(version: 2020_03_06_170531) do ...@@ -3264,6 +3264,7 @@ ActiveRecord::Schema.define(version: 2020_03_06_170531) do
t.integer "pages_access_level", null: false t.integer "pages_access_level", null: false
t.integer "forking_access_level" t.integer "forking_access_level"
t.index ["project_id"], name: "index_project_features_on_project_id", unique: true t.index ["project_id"], name: "index_project_features_on_project_id", unique: true
t.index ["project_id"], name: "index_project_features_on_project_id_bal_20", where: "(builds_access_level = 20)"
end end
create_table "project_group_links", id: :serial, force: :cascade do |t| create_table "project_group_links", id: :serial, force: :cascade do |t|
...@@ -3465,6 +3466,7 @@ ActiveRecord::Schema.define(version: 2020_03_06_170531) do ...@@ -3465,6 +3466,7 @@ ActiveRecord::Schema.define(version: 2020_03_06_170531) do
t.index ["created_at", "id"], name: "index_projects_api_created_at_id_desc", order: { id: :desc } t.index ["created_at", "id"], name: "index_projects_api_created_at_id_desc", order: { id: :desc }
t.index ["created_at", "id"], name: "index_projects_api_vis20_created_at", where: "(visibility_level = 20)" t.index ["created_at", "id"], name: "index_projects_api_vis20_created_at", where: "(visibility_level = 20)"
t.index ["created_at", "id"], name: "index_projects_on_created_at_and_id" t.index ["created_at", "id"], name: "index_projects_on_created_at_and_id"
t.index ["creator_id", "created_at"], name: "index_projects_on_mirror_creator_id_created_at", where: "((mirror = true) AND (mirror_trigger_builds = true))"
t.index ["creator_id"], name: "index_projects_on_creator_id" t.index ["creator_id"], name: "index_projects_on_creator_id"
t.index ["description"], name: "index_projects_on_description_trigram", opclass: :gin_trgm_ops, using: :gin t.index ["description"], name: "index_projects_on_description_trigram", opclass: :gin_trgm_ops, using: :gin
t.index ["id", "repository_storage", "last_repository_updated_at"], name: "idx_projects_on_repository_storage_last_repository_updated_at" t.index ["id", "repository_storage", "last_repository_updated_at"], name: "idx_projects_on_repository_storage_last_repository_updated_at"
......
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