Commit 618935e8 authored by Adam Hegyi's avatar Adam Hegyi

Merge branch '208889-optimize-event-counters' into 'master'

Optimize event counters in usage data

See merge request gitlab-org/gitlab!26444
parents 2cf75186 b9a4360d
---
title: Optimize event counters query performance in usage data
merge_request: 26444
author:
type: performance
# frozen_string_literal: true
class AddIndexOnAuthorIdAndCreatedAtToEvents < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :events, [:author_id, :created_at]
end
def down
remove_concurrent_index :events, [:author_id, :created_at]
end
end
......@@ -1616,6 +1616,7 @@ ActiveRecord::Schema.define(version: 2020_03_09_105539) do
t.string "target_type"
t.bigint "group_id"
t.index ["action"], name: "index_events_on_action"
t.index ["author_id", "created_at"], name: "index_events_on_author_id_and_created_at"
t.index ["author_id", "project_id"], name: "index_events_on_author_id_and_project_id"
t.index ["created_at", "author_id"], name: "analytics_index_events_on_created_at_and_author_id"
t.index ["group_id"], name: "index_events_on_group_id_partial", where: "(group_id IS NOT NULL)"
......
......@@ -28,7 +28,7 @@ module Gitlab
class BatchCounter
FALLBACK = -1
MIN_REQUIRED_BATCH_SIZE = 2_000
MIN_REQUIRED_BATCH_SIZE = 1_250
MAX_ALLOWED_LOOPS = 10_000
SLEEP_TIME_IN_SECONDS = 0.01 # 10 msec sleep
# Each query should take <<500ms https://gitlab.com/gitlab-org/gitlab/-/merge_requests/22705
......
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