Commit 652b09e8 authored by Adam Hegyi's avatar Adam Hegyi

Merge branch '208890-optimize-notes-and-suggestion-counters' into 'master'

Optimize suggestions counters in usage data

See merge request gitlab-org/gitlab!26443
parents 11b54e57 2de532e5
---
title: Optimize suggestions counters
merge_request: 26443
author:
type: performance
# frozen_string_literal: true
class AddIndexOnAuthorIdAndCreatedAtAndIdToNotes < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :notes, [:author_id, :created_at, :id]
remove_concurrent_index :notes, [:author_id, :created_at]
end
def down
add_concurrent_index :notes, [:author_id, :created_at]
remove_concurrent_index :notes, [:author_id, :created_at, :id]
end
end
...@@ -9519,7 +9519,7 @@ CREATE INDEX index_namespaces_on_type_partial ON public.namespaces USING btree ( ...@@ -9519,7 +9519,7 @@ CREATE INDEX index_namespaces_on_type_partial ON public.namespaces USING btree (
CREATE UNIQUE INDEX index_note_diff_files_on_diff_note_id ON public.note_diff_files USING btree (diff_note_id); CREATE UNIQUE INDEX index_note_diff_files_on_diff_note_id ON public.note_diff_files USING btree (diff_note_id);
CREATE INDEX index_notes_on_author_id_and_created_at ON public.notes USING btree (author_id, created_at); CREATE INDEX index_notes_on_author_id_and_created_at_and_id ON public.notes USING btree (author_id, created_at, id);
CREATE INDEX index_notes_on_commit_id ON public.notes USING btree (commit_id); CREATE INDEX index_notes_on_commit_id ON public.notes USING btree (commit_id);
...@@ -12925,5 +12925,6 @@ COPY "schema_migrations" (version) FROM STDIN; ...@@ -12925,5 +12925,6 @@ COPY "schema_migrations" (version) FROM STDIN;
20200326144443 20200326144443
20200326145443 20200326145443
20200330074719 20200330074719
20200330132913
\. \.
...@@ -232,7 +232,10 @@ module EE ...@@ -232,7 +232,10 @@ module EE
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),
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), :author_id) suggestions: distinct_count(::Note.with_suggestions.where(time_period),
:author_id,
start: ::User.minimum(:id),
finish: ::User.maximum(:id))
} }
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