Commit 94308390 authored by Tiger Watson's avatar Tiger Watson

Merge branch '197955-projects-api-improve-api-response-time-for-archived-true' into 'master'

Projects API: Improve API response time for archived=true

See merge request gitlab-org/gitlab!27717
parents 24baa659 b0e07fec
---
title: Improve API response for archived project searchs
merge_request: 27717
author:
type: performance
# frozen_string_literal: true
class AddApiIndexesForArchivedProjects < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
PUBLIC_AND_ARCHIVED_INDEX_NAME = "index_projects_api_created_at_id_for_archived_vis20"
ARCHIVED_INDEX_NAME = "index_projects_api_created_at_id_for_archived"
disable_ddl_transaction!
def up
add_concurrent_index :projects, [:created_at, :id],
where: "archived = true AND visibility_level = 20 AND pending_delete = false",
name: PUBLIC_AND_ARCHIVED_INDEX_NAME
add_concurrent_index :projects, [:created_at, :id], where: "archived = true AND pending_delete = false",
name: ARCHIVED_INDEX_NAME
end
def down
remove_concurrent_index_by_name :projects, ARCHIVED_INDEX_NAME
remove_concurrent_index_by_name :projects, PUBLIC_AND_ARCHIVED_INDEX_NAME
end
end
......@@ -9655,6 +9655,10 @@ CREATE UNIQUE INDEX index_project_tracing_settings_on_project_id ON public.proje
CREATE INDEX index_projects_api_created_at_id_desc ON public.projects USING btree (created_at, id DESC);
CREATE INDEX index_projects_api_created_at_id_for_archived ON public.projects USING btree (created_at, id) WHERE ((archived = true) AND (pending_delete = false));
CREATE INDEX index_projects_api_created_at_id_for_archived_vis20 ON public.projects USING btree (created_at, id) WHERE ((archived = true) AND (visibility_level = 20) AND (pending_delete = false));
CREATE INDEX index_projects_api_last_activity_at_id_desc ON public.projects USING btree (last_activity_at, id DESC);
CREATE INDEX index_projects_api_name_id_desc ON public.projects USING btree (name, id DESC);
......@@ -12795,6 +12799,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200320123839
20200323075043
20200323122201
20200323134519
20200324115359
\.
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