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
9787f5b3
Commit
9787f5b3
authored
3 years ago
by
Alex Pooley
Committed by
Mayra Cabrera
3 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Slow ci runners query at /api/:version/runners"
parent
a117dca9
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
7 deletions
+1
-7
app/models/ci/runner.rb
app/models/ci/runner.rb
+1
-7
No files found.
app/models/ci/runner.rb
View file @
9787f5b3
...
@@ -61,13 +61,7 @@ module Ci
...
@@ -61,13 +61,7 @@ module Ci
scope
:paused
,
->
{
where
(
active:
false
)
}
scope
:paused
,
->
{
where
(
active:
false
)
}
scope
:online
,
->
{
where
(
'contacted_at > ?'
,
online_contact_time_deadline
)
}
scope
:online
,
->
{
where
(
'contacted_at > ?'
,
online_contact_time_deadline
)
}
scope
:recent
,
->
{
where
(
'ci_runners.created_at > :date OR ci_runners.contacted_at > :date'
,
date:
3
.
months
.
ago
)
}
scope
:recent
,
->
{
where
(
'ci_runners.created_at > :date OR ci_runners.contacted_at > :date'
,
date:
3
.
months
.
ago
)
}
# The following query using negation is cheaper than using `contacted_at <= ?`
scope
:offline
,
->
{
where
(
arel_table
[
:contacted_at
].
lteq
(
online_contact_time_deadline
))
}
# because there are less runners online than have been created. The
# resulting query is quickly finding online ones and then uses the regular
# indexed search and rejects the ones that are in the previous set. If we
# did `contacted_at <= ?` the query would effectively have to do a seq
# scan.
scope
:offline
,
->
{
where
.
not
(
id:
online
)
}
scope
:not_connected
,
->
{
where
(
contacted_at:
nil
)
}
scope
:not_connected
,
->
{
where
(
contacted_at:
nil
)
}
scope
:ordered
,
->
{
order
(
id: :desc
)
}
scope
:ordered
,
->
{
order
(
id: :desc
)
}
...
...
This diff is collapsed.
Click to expand it.
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