Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/import_export/json/streaming_serializer.rb')
-rw-r--r--lib/gitlab/import_export/json/streaming_serializer.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/gitlab/import_export/json/streaming_serializer.rb b/lib/gitlab/import_export/json/streaming_serializer.rb
index 7f55a0a3821..20f9c668b9c 100644
--- a/lib/gitlab/import_export/json/streaming_serializer.rb
+++ b/lib/gitlab/import_export/json/streaming_serializer.rb
@@ -7,6 +7,15 @@ module Gitlab
include Gitlab::ImportExport::CommandLineUtil
BATCH_SIZE = 100
+ SMALLER_BATCH_SIZE = 20
+
+ def self.batch_size(exportable)
+ if Feature.enabled?(:export_reduce_relation_batch_size, exportable)
+ SMALLER_BATCH_SIZE
+ else
+ BATCH_SIZE
+ end
+ end
class Raw < String
def to_json(*_args)
@@ -60,7 +69,7 @@ module Gitlab
key_preloads = preloads&.dig(key)
records = records.preload(key_preloads) if key_preloads
- records.find_each(batch_size: BATCH_SIZE) do |record|
+ records.find_each(batch_size: batch_size) do |record|
items << Raw.new(record.to_json(options))
end
end
@@ -91,6 +100,10 @@ module Gitlab
def preloads
relations_schema[:preload]
end
+
+ def batch_size
+ @batch_size ||= self.class.batch_size(@exportable)
+ end
end
end
end