Commit c73bc888 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '246742-reduce-batch-loader-footprint-audit-events' into 'master'

Improve loading time for large number of events

See merge request gitlab-org/gitlab!43248
parents 6b5b16fc fd9ca353
......@@ -66,8 +66,8 @@ class AuditEvent < ApplicationRecord
end
def lazy_author
BatchLoader.for(author_id).batch(default_value: default_author_value) do |author_ids, loader|
User.where(id: author_ids).find_each do |user|
BatchLoader.for(author_id).batch(default_value: default_author_value, replace_methods: false) do |author_ids, loader|
User.select(:id, :name, :username).where(id: author_ids).find_each do |user|
loader.call(user.id, user)
end
end
......
......@@ -47,7 +47,7 @@ module EE
def lazy_entity
BatchLoader.for(entity_id)
.batch(
key: entity_type, default_value: ::Gitlab::Audit::NullEntity.new
key: entity_type, default_value: ::Gitlab::Audit::NullEntity.new, replace_methods: false
) do |ids, loader, args|
model = Object.const_get(args[:key], false)
model.where(id: ids).find_each { |record| loader.call(record.id, record) }
......
---
title: Reduce load time of large number of audit events
merge_request: 43248
author:
type: performance
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