Commit 02d6e4dc authored by Andreas Brandl's avatar Andreas Brandl

Add indexes for authenticated requests to projects API

This supports the default query we run when you hit /api/v4/projects as
an authenticated user.

Relates to https://gitlab.com/gitlab-org/gitlab/issues/36135
parent 09a2df90
---
title: Add index for authenticated requests to projects API default endpoint
merge_request: 19993
author:
type: performance
# frozen_string_literal: true
class AddIndexesForProjectsApiDefaultParamsAuthenticated < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :projects, %i(created_at id)
remove_concurrent_index_by_name :projects, 'index_projects_on_created_at'
end
def down
add_concurrent_index :projects, :created_at
remove_concurrent_index_by_name :projects, 'index_projects_on_created_at_and_id'
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2019_11_12_214305) do
ActiveRecord::Schema.define(version: 2019_11_12_221821) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm"
......@@ -3121,7 +3121,7 @@ ActiveRecord::Schema.define(version: 2019_11_12_214305) do
t.integer "marked_for_deletion_by_user_id"
t.index "lower((name)::text)", name: "index_projects_on_lower_name"
t.index ["archived", "pending_delete", "merge_requests_require_code_owner_approval"], name: "projects_requiring_code_owner_approval", where: "((pending_delete = false) AND (archived = false) AND (merge_requests_require_code_owner_approval = true))"
t.index ["created_at"], name: "index_projects_on_created_at"
t.index ["created_at", "id"], name: "index_projects_on_created_at_and_id"
t.index ["creator_id"], name: "index_projects_on_creator_id"
t.index ["description"], name: "index_projects_on_description_trigram", opclass: :gin_trgm_ops, using: :gin
t.index ["id", "repository_storage", "last_repository_updated_at"], name: "idx_projects_on_repository_storage_last_repository_updated_at"
......
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