Commit b7f24241 authored by Alper Akgun's avatar Alper Akgun

Optimize rolling 28 days snippets counter

Adding an index to eliminate filters in for the postgres optimizer
parent 73b7082c
---
title: Optimize rolling 28 days snippets counter
merge_request: 34918
author:
type: performance
# frozen_string_literal: true
class AddIndexOnIdAndCreatedAtToSnippets < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :snippets, [:id, :created_at]
end
def down
remove_concurrent_index :snippets, [:id, :created_at]
end
end
......@@ -10953,6 +10953,8 @@ CREATE INDEX index_snippets_on_description_trigram ON public.snippets USING gin
CREATE INDEX index_snippets_on_file_name_trigram ON public.snippets USING gin (file_name public.gin_trgm_ops);
CREATE INDEX index_snippets_on_id_and_created_at ON public.snippets USING btree (id, created_at);
CREATE INDEX index_snippets_on_id_and_type ON public.snippets USING btree (id, type);
CREATE INDEX index_snippets_on_project_id_and_visibility_level ON public.snippets USING btree (project_id, visibility_level);
......@@ -14075,6 +14077,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200617001637
20200617001848
20200617002030
20200618105638
20200618134223
20200618134723
\.
......
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