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
631f94b9
Commit
631f94b9
authored
Apr 19, 2021
by
Alex Pooley
Committed by
Imre Farkas
Apr 20, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Faster linear self_and_descendants query
parent
d9804f75
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
19 deletions
+1
-19
app/models/namespaces/traversal/linear.rb
app/models/namespaces/traversal/linear.rb
+1
-19
No files found.
app/models/namespaces/traversal/linear.rb
View file @
631f94b9
...
...
@@ -86,25 +86,7 @@ module Namespaces
raise
UnboundedSearch
.
new
(
'Must bound search by a top'
)
unless
top
without_sti_condition
.
traversal_ids_contains
(
latest_traversal_ids
(
top
))
end
# traversal_ids are a cached value.
#
# The traversal_ids value in a loaded object can become stale when compared
# to the database value. For example, if you load a hierarchy and then move
# a group, any previously loaded descendant objects will have out of date
# traversal_ids.
#
# To solve this problem, we never depend on the object's traversal_ids
# value. We always query the database first with a sub-select for the
# latest traversal_ids.
#
# Note that ActiveRecord will cache query results. You can avoid this by
# using `Model.uncached { ... }`
def
latest_traversal_ids
(
namespace
=
self
)
without_sti_condition
.
where
(
'id = (?)'
,
namespace
)
.
select
(
'traversal_ids as latest_traversal_ids'
)
.
traversal_ids_contains
(
"{
#{
top
.
id
}
}"
)
end
end
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