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
97ba8a76
Commit
97ba8a76
authored
Apr 08, 2021
by
Terri Chu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix N+1 queries for issues search
parent
f351b2b8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
4 deletions
+7
-4
app/models/issue.rb
app/models/issue.rb
+1
-1
changelogs/unreleased/230712-fix-n-1-queries-for-issues-search.yml
...s/unreleased/230712-fix-n-1-queries-for-issues-search.yml
+5
-0
ee/spec/features/search/elastic/global_search_spec.rb
ee/spec/features/search/elastic/global_search_spec.rb
+1
-3
No files found.
app/models/issue.rb
View file @
97ba8a76
...
...
@@ -114,7 +114,7 @@ class Issue < ApplicationRecord
scope
:order_severity_desc
,
->
{
includes
(
:issuable_severity
).
order
(
'issuable_severities.severity DESC NULLS LAST'
)
}
scope
:preload_associated_models
,
->
{
preload
(
:assignees
,
:labels
,
project: :namespace
)
}
scope
:with_web_entity_associations
,
->
{
preload
(
:author
,
:project
)
}
scope
:with_web_entity_associations
,
->
{
preload
(
:author
,
project:
[
:project_feature
,
:route
,
namespace: :route
]
)
}
scope
:with_label_attributes
,
->
(
label_attributes
)
{
joins
(
:labels
).
where
(
labels:
label_attributes
)
}
scope
:with_alert_management_alerts
,
->
{
joins
(
:alert_management_alert
)
}
scope
:with_prometheus_alert_events
,
->
{
joins
(
:issues_prometheus_alert_events
)
}
...
...
changelogs/unreleased/230712-fix-n-1-queries-for-issues-search.yml
0 → 100644
View file @
97ba8a76
---
title
:
Fix N+1 queries for issues search
merge_request
:
58915
author
:
type
:
performance
ee/spec/features/search/elastic/global_search_spec.rb
View file @
97ba8a76
...
...
@@ -45,9 +45,7 @@ RSpec.describe 'Global elastic search', :elastic, :sidekiq_inline do
let
(
:object
)
{
:issue
}
let
(
:creation_args
)
{
{
project:
project
,
title:
'initial'
}
}
let
(
:path
)
{
search_path
(
search:
'initial'
,
scope:
'issues'
)
}
# N+1 queries still exist and will be fixed per
# https://gitlab.com/gitlab-org/gitlab/-/issues/230712
let
(
:query_count_multiplier
)
{
1
}
let
(
:query_count_multiplier
)
{
0
}
it_behaves_like
'an efficient database result'
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