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
ab8cbdc1
Commit
ab8cbdc1
authored
May 25, 2020
by
Alishan Ladhani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use scope for issue search preloads
parent
0f4a3165
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
5 deletions
+13
-5
ee/changelogs/unreleased/ali-refactor-api-search-issue-preloads.yml
...ogs/unreleased/ali-refactor-api-search-issue-preloads.yml
+5
-0
ee/spec/requests/api/search_spec.rb
ee/spec/requests/api/search_spec.rb
+5
-3
lib/api/search.rb
lib/api/search.rb
+3
-2
No files found.
ee/changelogs/unreleased/ali-refactor-api-search-issue-preloads.yml
0 → 100644
View file @
ab8cbdc1
---
title
:
Improve performance of Advanced Search API (Issues scope) by preloading more associations
merge_request
:
30778
author
:
type
:
performance
ee/spec/requests/api/search_spec.rb
View file @
ab8cbdc1
...
...
@@ -160,19 +160,21 @@ describe API::Search do
context
'for issues scope'
,
:sidekiq_inline
do
before
do
create_list
(
:issue
,
4
,
project:
project
)
create_list
(
:issue
,
2
,
project:
project
)
ensure_elasticsearch_index!
end
it
'avoids N+1 queries'
do
control
=
ActiveRecord
::
QueryRecorder
.
new
{
get
api
(
endpoint
,
user
),
params:
{
scope:
'issues'
,
search:
'*'
}
}
new_issues
=
create_list
(
:issue
,
4
,
project:
project
)
create_list
(
:issue
,
2
,
project:
project
)
create_list
(
:issue
,
2
,
project:
create
(
:project
,
group:
group
))
create_list
(
:issue
,
2
)
ensure_elasticsearch_index!
# Some N+1 queries still exist
expect
{
get
api
(
endpoint
,
user
),
params:
{
scope:
'issues'
,
search:
'*'
}
}.
not_to
exceed_query_limit
(
control
.
count
+
new_issues
.
count
*
4
)
expect
{
get
api
(
endpoint
,
user
),
params:
{
scope:
'issues'
,
search:
'*'
}
}.
not_to
exceed_query_limit
(
control
.
count
+
2
)
end
it_behaves_like
'pagination'
,
scope:
'issues'
...
...
lib/api/search.rb
View file @
ab8cbdc1
...
...
@@ -21,8 +21,9 @@ module API
}.
freeze
SCOPE_PRELOAD_METHOD
=
{
merge_requests: :with_api_entity_associations
,
projects: :with_api_entity_associations
merge_requests: :with_api_entity_associations
,
projects: :with_api_entity_associations
,
issues: :with_api_entity_associations
}.
freeze
def
search
(
additional_params
=
{})
...
...
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