Commit 43996cb8 authored by Mikołaj Wawrzyniak's avatar Mikołaj Wawrzyniak

Merge branch 'mwaw/add-sync-index-to-events-on-id-creeated_at-343679' into 'master'

Resolve "SaaS Service Ping Metrics Failures causing null UMAU value"

See merge request gitlab-org/gitlab!73670
parents 3bb9f719 7c60b263
# frozen_string_literal: true
class AddIndexOnEventsUsingBtreeCreatedAtId < Gitlab::Database::Migration[1.0]
INDEX_NAME = 'index_events_on_created_at_and_id'
TABLE = :events
COLUMNS = %i[created_at id]
CONSTRAINTS = "created_at > '2021-08-27 00:00:00+00'::timestamp with time zone"
disable_ddl_transaction!
def up
add_concurrent_index TABLE, COLUMNS, name: INDEX_NAME, where: CONSTRAINTS
end
def down
remove_concurrent_index TABLE, COLUMNS, name: INDEX_NAME, where: CONSTRAINTS
end
end
2ed9198926eb0579fccd4a8b1866f10ba4f42683d676e0664db3fadefe0bed39
\ No newline at end of file
......@@ -25853,6 +25853,8 @@ CREATE INDEX index_events_on_author_id_and_created_at_merge_requests ON events U
CREATE INDEX index_events_on_author_id_and_project_id ON events USING btree (author_id, project_id);
CREATE INDEX index_events_on_created_at_and_id ON events USING btree (created_at, id) WHERE (created_at > '2021-08-27 00:00:00+00'::timestamp with time zone);
CREATE INDEX index_events_on_group_id_partial ON events USING btree (group_id) WHERE (group_id IS NOT NULL);
CREATE INDEX index_events_on_project_id_and_created_at ON events USING btree (project_id, created_at);
......@@ -15,7 +15,7 @@ RSpec.describe Gitlab::UsageDataNonSqlMetrics do
described_class.uncached_data
end
expect(recorder.count).to eq(57)
expect(recorder.count).to eq(59)
end
end
end
......@@ -723,7 +723,9 @@ module Gitlab
else
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable UsageData/LargeTable
estimate_batch_distinct_count(::Event.where(time_period), :author_id)
start = ::Event.where(time_period).select(:id).order(created_at: :asc).first&.id
finish = ::Event.where(time_period).select(:id).order(created_at: :asc).first&.id
estimate_batch_distinct_count(::Event.where(time_period), :author_id, start: start, finish: finish)
# rubocop: enable UsageData/LargeTable
# rubocop: enable CodeReuse/ActiveRecord
end
......
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