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
42d94806
Commit
42d94806
authored
Mar 13, 2020
by
alinamihaila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize members query performance in usage data
Add index on user_id, type, source_type,ldap, created_at on members
parent
28f33dcf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
1 deletion
+25
-1
changelogs/unreleased/210051-optimize-or-remove-ldap_users-counter.yml
...released/210051-optimize-or-remove-ldap_users-counter.yml
+5
-0
db/migrate/20200313123934_add_index_on_user_id_type_source_type_ldap_and_created_at_to_members.rb
...ser_id_type_source_type_ldap_and_created_at_to_members.rb
+18
-0
db/schema.rb
db/schema.rb
+2
-1
No files found.
changelogs/unreleased/210051-optimize-or-remove-ldap_users-counter.yml
0 → 100644
View file @
42d94806
---
title
:
Optimize members counters query performance in usage data
merge_request
:
27197
author
:
type
:
performance
db/migrate/20200313123934_add_index_on_user_id_type_source_type_ldap_and_created_at_to_members.rb
0 → 100644
View file @
42d94806
# frozen_string_literal: true
class
AddIndexOnUserIdTypeSourceTypeLdapAndCreatedAtToMembers
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
INDEX_NAME
=
'index_members_on_user_id_type_source_type_ldap_and_created_at'
disable_ddl_transaction!
def
up
add_concurrent_index
:members
,
[
:user_id
,
:type
,
:source_type
,
:ldap
,
:created_at
],
where:
"ldap = TRUE AND type = 'GroupMember' AND source_type = 'Namespace'"
,
name:
INDEX_NAME
end
def
down
remove_concurrent_index
:members
,
INDEX_NAME
end
end
db/schema.rb
View file @
42d94806
...
...
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2020_03_1
2_163407
)
do
ActiveRecord
::
Schema
.
define
(
version:
2020_03_1
3_123934
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"pg_trgm"
...
...
@@ -2442,6 +2442,7 @@ ActiveRecord::Schema.define(version: 2020_03_12_163407) do
t
.
index
[
"invite_token"
],
name:
"index_members_on_invite_token"
,
unique:
true
t
.
index
[
"requested_at"
],
name:
"index_members_on_requested_at"
t
.
index
[
"source_id"
,
"source_type"
],
name:
"index_members_on_source_id_and_source_type"
t
.
index
[
"user_id"
,
"type"
,
"source_type"
,
"ldap"
,
"created_at"
],
name:
"index_members_on_user_id_type_source_type_ldap_and_created_at"
,
where:
"((ldap = true) AND ((type)::text = 'GroupMember'::text) AND ((source_type)::text = 'Namespace'::text))"
t
.
index
[
"user_id"
],
name:
"index_members_on_user_id"
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