Commit b032cc78 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add indices to abuse_reports table

Add indices on user_id and reporter_id to abuse_reports table.
Also fix the use of include for /admin/abuse_reports page
Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent f08be33b
...@@ -4,7 +4,7 @@ class Admin::AbuseReportsController < Admin::ApplicationController ...@@ -4,7 +4,7 @@ class Admin::AbuseReportsController < Admin::ApplicationController
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def index def index
@abuse_reports = AbuseReport.order(id: :desc).page(params[:page]) @abuse_reports = AbuseReport.order(id: :desc).page(params[:page])
@abuse_reports.includes(:reporter, :user) @abuse_reports = @abuse_reports.includes(:user, :reporter)
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
---
title: Improve performance of admin/abuse_reports page
merge_request: 19630
author:
type: performance
# frozen_string_literal: true
class AddIndicesToAbuseReports < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :abuse_reports, :user_id
end
def down
remove_concurrent_index :abuse_reports, :user_id
end
end
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2019_11_05_094625) do ActiveRecord::Schema.define(version: 2019_11_05_140942) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm" enable_extension "pg_trgm"
...@@ -24,6 +24,7 @@ ActiveRecord::Schema.define(version: 2019_11_05_094625) do ...@@ -24,6 +24,7 @@ ActiveRecord::Schema.define(version: 2019_11_05_094625) do
t.datetime "updated_at" t.datetime "updated_at"
t.text "message_html" t.text "message_html"
t.integer "cached_markdown_version" t.integer "cached_markdown_version"
t.index ["user_id"], name: "index_abuse_reports_on_user_id"
end end
create_table "alerts_service_data", force: :cascade do |t| create_table "alerts_service_data", force: :cascade do |t|
......
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