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
96c78eed
Commit
96c78eed
authored
Jun 10, 2020
by
Alper Akgun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Harden CI pipelines usage data queries
Adds an index for ci_builds.source Adds start/finish values
parent
fec817e8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
6 deletions
+31
-6
changelogs/unreleased/220477-harden-ci-pipelines-usage-data-queries.yml
...eleased/220477-harden-ci-pipelines-usage-data-queries.yml
+5
-0
db/post_migrate/20200608075553_add_index_on_user_id_and_created_at_and_source_to_ci_pipelines.rb
...x_on_user_id_and_created_at_and_source_to_ci_pipelines.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
+5
-5
No files found.
changelogs/unreleased/220477-harden-ci-pipelines-usage-data-queries.yml
0 → 100644
View file @
96c78eed
---
title
:
Harden CI pipelines usage data queries with an index
merge_request
:
34045
author
:
type
:
performance
db/post_migrate/20200608075553_add_index_on_user_id_and_created_at_and_source_to_ci_pipelines.rb
0 → 100644
View file @
96c78eed
# frozen_string_literal: true
class
AddIndexOnUserIdAndCreatedAtAndSourceToCiPipelines
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
add_concurrent_index
:ci_pipelines
,
[
:user_id
,
:created_at
,
:source
]
remove_concurrent_index
:ci_pipelines
,
[
:user_id
,
:created_at
]
end
def
down
add_concurrent_index
:ci_pipelines
,
[
:user_id
,
:created_at
]
remove_concurrent_index
:ci_pipelines
,
[
:user_id
,
:created_at
,
:source
]
end
end
db/structure.sql
View file @
96c78eed
...
@@ -9450,7 +9450,7 @@ CREATE INDEX index_ci_pipelines_on_project_idandrefandiddesc ON public.ci_pipeli
...
@@ -9450,7 +9450,7 @@ CREATE INDEX index_ci_pipelines_on_project_idandrefandiddesc ON public.ci_pipeli
CREATE
INDEX
index_ci_pipelines_on_status
ON
public
.
ci_pipelines
USING
btree
(
status
);
CREATE
INDEX
index_ci_pipelines_on_status
ON
public
.
ci_pipelines
USING
btree
(
status
);
CREATE
INDEX
index_ci_pipelines_on_user_id_and_created_at
ON
public
.
ci_pipelines
USING
btree
(
user_id
,
created_at
);
CREATE
INDEX
index_ci_pipelines_on_user_id_and_created_at
_and_source
ON
public
.
ci_pipelines
USING
btree
(
user_id
,
created_at
,
source
);
CREATE
INDEX
index_ci_refs_on_last_updated_by_pipeline_id
ON
public
.
ci_refs
USING
btree
(
last_updated_by_pipeline_id
);
CREATE
INDEX
index_ci_refs_on_last_updated_by_pipeline_id
ON
public
.
ci_refs
USING
btree
(
last_updated_by_pipeline_id
);
...
@@ -13835,5 +13835,6 @@ COPY "schema_migrations" (version) FROM STDIN;
...
@@ -13835,5 +13835,6 @@ COPY "schema_migrations" (version) FROM STDIN;
20200601210148
20200601210148
20200603073101
20200603073101
20200604143628
20200604143628
20200608075553
\
.
\
.
ee/lib/ee/gitlab/usage_data.rb
View file @
96c78eed
...
@@ -341,12 +341,12 @@ module EE
...
@@ -341,12 +341,12 @@ module EE
def
usage_activity_by_stage_verify
(
time_period
)
def
usage_activity_by_stage_verify
(
time_period
)
{
{
ci_builds:
distinct_count
(
::
Ci
::
Build
.
where
(
time_period
),
:user_id
),
ci_builds:
distinct_count
(
::
Ci
::
Build
.
where
(
time_period
),
:user_id
),
ci_external_pipelines:
distinct_count
(
::
Ci
::
Pipeline
.
external
.
where
(
time_period
),
:user_id
),
ci_external_pipelines:
distinct_count
(
::
Ci
::
Pipeline
.
external
.
where
(
time_period
),
:user_id
,
start:
user_minimum_id
,
finish:
user_maximum_id
),
ci_internal_pipelines:
distinct_count
(
::
Ci
::
Pipeline
.
internal
.
where
(
time_period
),
:user_id
),
ci_internal_pipelines:
distinct_count
(
::
Ci
::
Pipeline
.
internal
.
where
(
time_period
),
:user_id
,
start:
user_minimum_id
,
finish:
user_maximum_id
),
ci_pipeline_config_auto_devops:
distinct_count
(
::
Ci
::
Pipeline
.
auto_devops_source
.
where
(
time_period
),
:user_id
),
ci_pipeline_config_auto_devops:
distinct_count
(
::
Ci
::
Pipeline
.
auto_devops_source
.
where
(
time_period
),
:user_id
,
start:
user_minimum_id
,
finish:
user_maximum_id
),
ci_pipeline_config_repository:
distinct_count
(
::
Ci
::
Pipeline
.
repository_source
.
where
(
time_period
),
:user_id
),
ci_pipeline_config_repository:
distinct_count
(
::
Ci
::
Pipeline
.
repository_source
.
where
(
time_period
),
:user_id
,
start:
user_minimum_id
,
finish:
user_maximum_id
),
ci_pipeline_schedules:
distinct_count
(
::
Ci
::
PipelineSchedule
.
where
(
time_period
),
:owner_id
),
ci_pipeline_schedules:
distinct_count
(
::
Ci
::
PipelineSchedule
.
where
(
time_period
),
:owner_id
),
ci_pipelines:
distinct_count
(
::
Ci
::
Pipeline
.
where
(
time_period
),
:user_id
),
ci_pipelines:
distinct_count
(
::
Ci
::
Pipeline
.
where
(
time_period
),
:user_id
,
start:
user_minimum_id
,
finish:
user_maximum_id
),
ci_triggers:
distinct_count
(
::
Ci
::
Trigger
.
where
(
time_period
),
:owner_id
),
ci_triggers:
distinct_count
(
::
Ci
::
Trigger
.
where
(
time_period
),
:owner_id
),
clusters_applications_runner:
cluster_applications_user_distinct_count
(
::
Clusters
::
Applications
::
Runner
,
time_period
),
clusters_applications_runner:
cluster_applications_user_distinct_count
(
::
Clusters
::
Applications
::
Runner
,
time_period
),
projects_reporting_ci_cd_back_to_github:
distinct_count
(
::
Project
.
with_github_service_pipeline_events
.
where
(
time_period
),
:creator_id
)
projects_reporting_ci_cd_back_to_github:
distinct_count
(
::
Project
.
with_github_service_pipeline_events
.
where
(
time_period
),
:creator_id
)
...
...
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