Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
63d766a6
Commit
63d766a6
authored
Mar 20, 2020
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve performance RegistryBackfillService with bulk insert
parent
b617c71f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
14 deletions
+17
-14
ee/app/models/geo/base_registry.rb
ee/app/models/geo/base_registry.rb
+7
-6
ee/app/models/geo/upload_registry.rb
ee/app/models/geo/upload_registry.rb
+8
-6
ee/app/services/geo/registry_consistency_service.rb
ee/app/services/geo/registry_consistency_service.rb
+2
-2
No files found.
ee/app/models/geo/base_registry.rb
View file @
63d766a6
...
...
@@ -15,12 +15,13 @@ class Geo::BaseRegistry < Geo::TrackingBase
where
.
not
(
self
::
MODEL_FOREIGN_KEY
=>
ids
)
end
# TODO: Investigate replacing this with bulk insert (there was an obstacle).
# https://gitlab.com/gitlab-org/gitlab/issues/197310
def
self
.
insert_for_model_ids
(
ids
)
ids
.
map
do
|
id
|
registry
=
create
(
self
::
MODEL_FOREIGN_KEY
=>
id
)
registry
.
id
end
.
compact
inserts
=
ids
.
map
do
|
id
|
{
self
::
MODEL_FOREIGN_KEY
=>
id
,
created_at:
Time
.
zone
.
now
}
end
ActiveRecord
::
InsertAll
.
new
(
self
,
inserts
,
on_duplicate: :skip
,
returning:
[
:id
])
.
execute
end
end
ee/app/models/geo/upload_registry.rb
View file @
63d766a6
...
...
@@ -28,13 +28,15 @@ class Geo::UploadRegistry < Geo::BaseRegistry
false
end
# TODO: Investigate replacing this with bulk insert (there was an obstacle).
# https://gitlab.com/gitlab-org/gitlab/issues/197310
def
self
.
insert_for_model_ids
(
attrs
)
attrs
.
map
do
|
file_id
,
file_type
|
registry
=
create
(
file_id:
file_id
,
file_type:
file_type
)
registry
.
id
end
.
compact
inserts
=
attrs
.
map
do
|
file_id
,
file_type
|
{
file_id:
file_id
,
file_type:
file_type
,
created_at:
Time
.
zone
.
now
}
end
ActiveRecord
::
InsertAll
.
new
(
self
,
inserts
,
on_duplicate: :skip
,
returning:
[
:id
])
.
execute
.
pluck
(
'id'
)
end
def
self
.
with_search
(
query
)
...
...
ee/app/services/geo/registry_consistency_service.rb
View file @
63d766a6
...
...
@@ -99,8 +99,8 @@ module Geo
registry_class:
registry_class
.
name
,
start:
range
.
first
,
finish:
range
.
last
,
created:
created
.
size
,
failed_to_create:
untracked
.
size
-
created
.
size
created:
created
.
length
,
failed_to_create:
untracked
.
length
-
created
.
length
}
)
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment