Commit 5b50e78a authored by Toon Claes's avatar Toon Claes

Merge branch...

Merge branch '213799-optimize-usage_activity_by_stage-projects_with_repositories_enabled' into 'master'

Optimize projects with repositories enabled

See merge request gitlab-org/gitlab!29117
parents 20199b04 045d023e
---
title: Optimize projects with repositories enabled usage data
merge_request: 29117
author:
type: performance
# frozen_string_literal: true
class AddIndexOnCreatorIdAndIdOnProjects < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :projects, [:creator_id, :id]
end
def down
remove_concurrent_index :projects, [:creator_id, :id]
end
end
...@@ -9918,6 +9918,8 @@ CREATE INDEX index_projects_on_creator_id_and_created_at ON public.projects USIN ...@@ -9918,6 +9918,8 @@ CREATE INDEX index_projects_on_creator_id_and_created_at ON public.projects USIN
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_creator_id_and_created_at_and_id ON public.projects USING btree (creator_id, created_at, id);
CREATE INDEX index_projects_on_creator_id_and_id ON public.projects USING btree (creator_id, 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));
...@@ -13131,6 +13133,7 @@ COPY "schema_migrations" (version) FROM STDIN; ...@@ -13131,6 +13133,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200407094005 20200407094005
20200407094923 20200407094923
20200408110856 20200408110856
20200408153842
20200408175424 20200408175424
\. \.
...@@ -234,7 +234,10 @@ module EE ...@@ -234,7 +234,10 @@ module EE
merge_requests_with_optional_codeowners: distinct_count(::ApprovalMergeRequestRule.code_owner_approval_optional.where(time_period), :merge_request_id), merge_requests_with_optional_codeowners: distinct_count(::ApprovalMergeRequestRule.code_owner_approval_optional.where(time_period), :merge_request_id),
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,
start: ::User.minimum(:id),
finish: ::User.maximum(:id)),
protected_branches: distinct_count(::Project.with_protected_branches.where(time_period), :creator_id, start: ::User.minimum(:id), finish: ::User.maximum(: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),
......
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