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
e3c69613
Commit
e3c69613
authored
Mar 16, 2020
by
Alex Buijs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize query for usage ping
Query by adding an index and using batch counting
parent
7d8ed431
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
2 deletions
+27
-2
changelogs/unreleased/208923-enable-batch-counting-for-some-individual-queries-2.yml
...3-enable-batch-counting-for-some-individual-queries-2.yml
+5
-0
db/migrate/20200316162648_add_index_on_namespace_id_and_id_to_projects.rb
...316162648_add_index_on_namespace_id_and_id_to_projects.rb
+19
-0
db/structure.sql
db/structure.sql
+2
-1
ee/lib/ee/gitlab/usage_data.rb
ee/lib/ee/gitlab/usage_data.rb
+1
-1
No files found.
changelogs/unreleased/208923-enable-batch-counting-for-some-individual-queries-2.yml
0 → 100644
View file @
e3c69613
---
title
:
Optimize template_repositories query by using batch counting
merge_request
:
27352
author
:
type
:
performance
db/migrate/20200316162648_add_index_on_namespace_id_and_id_to_projects.rb
0 → 100644
View file @
e3c69613
# frozen_string_literal: true
class
AddIndexOnNamespaceIdAndIdToProjects
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
add_concurrent_index
:projects
,
[
:namespace_id
,
:id
]
remove_concurrent_index
:projects
,
:namespace_id
end
def
down
add_concurrent_index
:projects
,
:namespace_id
remove_concurrent_index
:projects
,
[
:namespace_id
,
:id
]
end
end
db/structure.sql
View file @
e3c69613
...
...
@@ -9657,7 +9657,7 @@ CREATE INDEX index_projects_on_name_and_id ON public.projects USING btree (name,
CREATE
INDEX
index_projects_on_name_trigram
ON
public
.
projects
USING
gin
(
name
public
.
gin_trgm_ops
);
CREATE
INDEX
index_projects_on_namespace_id
ON
public
.
projects
USING
btree
(
namespace_
id
);
CREATE
INDEX
index_projects_on_namespace_id
_and_id
ON
public
.
projects
USING
btree
(
namespace_id
,
id
);
CREATE
INDEX
index_projects_on_path_and_id
ON
public
.
projects
USING
btree
(
path
,
id
);
...
...
@@ -12702,6 +12702,7 @@ INSERT INTO "schema_migrations" (version) VALUES
(
'20200313101649'
),
(
'20200313123934'
),
(
'20200316111759'
),
(
'20200316162648'
),
(
'20200316173312'
),
(
'20200317142110'
),
(
'20200318152134'
),
...
...
ee/lib/ee/gitlab/usage_data.rb
View file @
e3c69613
...
...
@@ -157,7 +157,7 @@ module EE
projects_with_packages:
count
(
::
Packages
::
Package
.
select
(
'distinct project_id'
),
batch:
false
),
projects_with_prometheus_alerts:
distinct_count
(
PrometheusAlert
,
:project_id
),
projects_with_tracing_enabled:
count
(
ProjectTracingSetting
),
template_repositories:
count
(
::
Project
.
with_repos_templates
,
batch:
false
)
+
count
(
::
Project
.
with_groups_level_repos_templates
,
batch:
false
)
template_repositories:
count
(
::
Project
.
with_repos_templates
)
+
count
(
::
Project
.
with_groups_level_repos_templates
)
},
service_desk_counts
,
security_products_usage
,
...
...
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