Commit f191e9f4 authored by Alper Akgun's avatar Alper Akgun Committed by Mayra Cabrera

Optimizes the todo counter query

adds an index for batch counting in usage data
parent 0494c5ba
---
title: Optimize todos counters in usage data
merge_request: 26442
author:
type: performance
# frozen_string_literal: true
class AddIndexOnAuthorIdAndCreatedAtToTodos < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :todos, [:author_id, :created_at]
end
def down
remove_concurrent_index :todos, [:author_id, :created_at]
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: 2020_03_04_160823) do ActiveRecord::Schema.define(version: 2020_03_06_170531) 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"
...@@ -4150,6 +4150,7 @@ ActiveRecord::Schema.define(version: 2020_03_04_160823) do ...@@ -4150,6 +4150,7 @@ ActiveRecord::Schema.define(version: 2020_03_04_160823) do
t.integer "note_id" t.integer "note_id"
t.string "commit_id" t.string "commit_id"
t.integer "group_id" t.integer "group_id"
t.index ["author_id", "created_at"], name: "index_todos_on_author_id_and_created_at"
t.index ["author_id"], name: "index_todos_on_author_id" t.index ["author_id"], name: "index_todos_on_author_id"
t.index ["commit_id"], name: "index_todos_on_commit_id" t.index ["commit_id"], name: "index_todos_on_commit_id"
t.index ["group_id"], name: "index_todos_on_group_id" t.index ["group_id"], name: "index_todos_on_group_id"
......
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