Commit 327b4f73 authored by Toon Claes's avatar Toon Claes

Merge branch '213800-optimize-usage_activity_by_stage-create-protected_branches' into 'master'

Optimize usage_activity_by_stage.create.protected_branches

Closes #213800

See merge request gitlab-org/gitlab!29148
parents da32e10d a2270d38
---
title: Optimize protected branches usage data
merge_request: 29148
author:
type: performance
# frozen_string_literal: true
class AddIndexOnCreatorIdCreatedAtIdToProjectsTable < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :projects, [:creator_id, :created_at, :id]
end
def down
remove_concurrent_index :projects, [:creator_id, :created_at, :id]
end
end
...@@ -9884,6 +9884,8 @@ CREATE INDEX index_projects_on_created_at_and_id ON public.projects USING btree ...@@ -9884,6 +9884,8 @@ CREATE INDEX index_projects_on_created_at_and_id ON public.projects USING btree
CREATE INDEX index_projects_on_creator_id_and_created_at ON public.projects USING btree (creator_id, created_at); CREATE INDEX index_projects_on_creator_id_and_created_at ON public.projects USING btree (creator_id, created_at);
CREATE INDEX index_projects_on_creator_id_and_created_at_and_id ON public.projects USING btree (creator_id, created_at, id);
CREATE INDEX index_projects_on_description_trigram ON public.projects USING gin (description public.gin_trgm_ops); CREATE INDEX index_projects_on_description_trigram ON public.projects USING gin (description public.gin_trgm_ops);
CREATE INDEX index_projects_on_id_and_archived_and_pending_delete ON public.projects USING btree (id) WHERE ((archived = false) AND (pending_delete = false)); CREATE INDEX index_projects_on_id_and_archived_and_pending_delete ON public.projects USING btree (id) WHERE ((archived = false) AND (pending_delete = false));
...@@ -13092,5 +13094,6 @@ COPY "schema_migrations" (version) FROM STDIN; ...@@ -13092,5 +13094,6 @@ COPY "schema_migrations" (version) FROM STDIN;
20200407094005 20200407094005
20200407094923 20200407094923
20200408110856 20200408110856
20200408175424
\. \.
...@@ -235,7 +235,7 @@ module EE ...@@ -235,7 +235,7 @@ module EE
merge_requests_with_required_codeowners: distinct_count(::ApprovalMergeRequestRule.code_owner_approval_required.where(time_period), :merge_request_id), merge_requests_with_required_codeowners: distinct_count(::ApprovalMergeRequestRule.code_owner_approval_required.where(time_period), :merge_request_id),
projects_imported_from_github: distinct_count(::Project.github_imported.where(time_period), :creator_id), projects_imported_from_github: distinct_count(::Project.github_imported.where(time_period), :creator_id),
projects_with_repositories_enabled: distinct_count(::Project.with_repositories_enabled.where(time_period), :creator_id), projects_with_repositories_enabled: distinct_count(::Project.with_repositories_enabled.where(time_period), :creator_id),
protected_branches: distinct_count(::Project.with_protected_branches.where(time_period), :creator_id), protected_branches: distinct_count(::Project.with_protected_branches.where(time_period), :creator_id, start: ::User.minimum(:id), finish: ::User.maximum(:id)),
remote_mirrors: distinct_count(::Project.with_remote_mirrors.where(time_period), :creator_id), remote_mirrors: distinct_count(::Project.with_remote_mirrors.where(time_period), :creator_id),
snippets: distinct_count(::Snippet.where(time_period), :author_id), snippets: distinct_count(::Snippet.where(time_period), :author_id),
suggestions: distinct_count(::Note.with_suggestions.where(time_period), suggestions: distinct_count(::Note.with_suggestions.where(time_period),
......
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