Commit b617c71f authored by Toon Claes's avatar Toon Claes

Merge branch...

Merge branch '197957-projects-api-improve-response-time-for-created_at-desc-order-and-visibility-internal' into 'master'

Fix slow API response for internal projects sorted by reverse created_at

See merge request gitlab-org/gitlab!28038
parents 6fb6be1a 9ef8c27a
---
title: Improve API response for descending internal project searches
merge_request: 28038
author:
type: performance
# frozen_string_literal: true
class AddApiIndexForInternalProjects < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
INTERNAL_PROJECTS_INDEX_NAME = "index_projects_api_created_at_id_for_vis10"
disable_ddl_transaction!
def up
add_concurrent_index :projects, [:created_at, :id],
where: "visibility_level = 10 AND pending_delete = false",
name: INTERNAL_PROJECTS_INDEX_NAME
end
def down
remove_concurrent_index_by_name :projects, INTERNAL_PROJECTS_INDEX_NAME
end
end
......@@ -9685,6 +9685,8 @@ CREATE INDEX index_projects_api_created_at_id_for_archived ON public.projects US
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_created_at_id_for_vis10 ON public.projects USING btree (created_at, id) WHERE ((visibility_level = 10) 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);
......@@ -12839,5 +12841,6 @@ COPY "schema_migrations" (version) FROM STDIN;
20200323134519
20200324115359
20200325160952
20200325183636
\.
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