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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
a7a3636d
Commit
a7a3636d
authored
Nov 29, 2016
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'removing_unnecessary_indexes' into 'master'
Remove unnecessary database indices See merge request !7789
parents
b8f9949a
a48ef156
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
9 deletions
+37
-9
changelogs/unreleased/removing_unnecessary_indexes.yml
changelogs/unreleased/removing_unnecessary_indexes.yml
+4
-0
db/migrate/20161128142110_remove_unnecessary_indexes.rb
db/migrate/20161128142110_remove_unnecessary_indexes.rb
+33
-0
db/schema.rb
db/schema.rb
+0
-9
No files found.
changelogs/unreleased/removing_unnecessary_indexes.yml
0 → 100644
View file @
a7a3636d
---
title
:
Remove unnecessary database indices
merge_request
:
author
:
db/migrate/20161128142110_remove_unnecessary_indexes.rb
0 → 100644
View file @
a7a3636d
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
RemoveUnnecessaryIndexes
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
disable_ddl_transaction!
DOWNTIME
=
false
def
up
remove_index
:labels
,
column: :group_id
if
index_exists?
(
:labels
,
:group_id
)
remove_index
:award_emoji
,
column: :user_id
if
index_exists?
(
:award_emoji
,
:user_id
)
remove_index
:ci_builds
,
column: :commit_id
if
index_exists?
(
:ci_builds
,
:commit_id
)
remove_index
:deployments
,
column: :project_id
if
index_exists?
(
:deployments
,
:project_id
)
remove_index
:deployments
,
column:
[
"project_id"
,
"environment_id"
]
if
index_exists?
(
:deployments
,
[
"project_id"
,
"environment_id"
])
remove_index
:lists
,
column: :board_id
if
index_exists?
(
:lists
,
:board_id
)
remove_index
:milestones
,
column: :project_id
if
index_exists?
(
:milestones
,
:project_id
)
remove_index
:notes
,
column: :project_id
if
index_exists?
(
:notes
,
:project_id
)
remove_index
:users_star_projects
,
column: :user_id
if
index_exists?
(
:users_star_projects
,
:user_id
)
end
def
down
add_concurrent_index
:labels
,
:group_id
add_concurrent_index
:award_emoji
,
:user_id
add_concurrent_index
:ci_builds
,
:commit_id
add_concurrent_index
:deployments
,
:project_id
add_concurrent_index
:deployments
,
[
"project_id"
,
"environment_id"
]
add_concurrent_index
:lists
,
:board_id
add_concurrent_index
:milestones
,
:project_id
add_concurrent_index
:notes
,
:project_id
add_concurrent_index
:users_star_projects
,
:user_id
end
end
db/schema.rb
View file @
a7a3636d
...
...
@@ -132,7 +132,6 @@ ActiveRecord::Schema.define(version: 20161128161412) do
add_index
"award_emoji"
,
[
"awardable_type"
,
"awardable_id"
],
name:
"index_award_emoji_on_awardable_type_and_awardable_id"
,
using: :btree
add_index
"award_emoji"
,
[
"user_id"
,
"name"
],
name:
"index_award_emoji_on_user_id_and_name"
,
using: :btree
add_index
"award_emoji"
,
[
"user_id"
],
name:
"index_award_emoji_on_user_id"
,
using: :btree
create_table
"boards"
,
force: :cascade
do
|
t
|
t
.
integer
"project_id"
,
null:
false
...
...
@@ -220,7 +219,6 @@ ActiveRecord::Schema.define(version: 20161128161412) do
add_index
"ci_builds"
,
[
"commit_id"
,
"status"
,
"type"
],
name:
"index_ci_builds_on_commit_id_and_status_and_type"
,
using: :btree
add_index
"ci_builds"
,
[
"commit_id"
,
"type"
,
"name"
,
"ref"
],
name:
"index_ci_builds_on_commit_id_and_type_and_name_and_ref"
,
using: :btree
add_index
"ci_builds"
,
[
"commit_id"
,
"type"
,
"ref"
],
name:
"index_ci_builds_on_commit_id_and_type_and_ref"
,
using: :btree
add_index
"ci_builds"
,
[
"commit_id"
],
name:
"index_ci_builds_on_commit_id"
,
using: :btree
add_index
"ci_builds"
,
[
"gl_project_id"
],
name:
"index_ci_builds_on_gl_project_id"
,
using: :btree
add_index
"ci_builds"
,
[
"project_id"
],
name:
"index_ci_builds_on_project_id"
,
using: :btree
add_index
"ci_builds"
,
[
"runner_id"
],
name:
"index_ci_builds_on_runner_id"
,
using: :btree
...
...
@@ -410,9 +408,7 @@ ActiveRecord::Schema.define(version: 20161128161412) do
end
add_index
"deployments"
,
[
"project_id"
,
"environment_id"
,
"iid"
],
name:
"index_deployments_on_project_id_and_environment_id_and_iid"
,
using: :btree
add_index
"deployments"
,
[
"project_id"
,
"environment_id"
],
name:
"index_deployments_on_project_id_and_environment_id"
,
using: :btree
add_index
"deployments"
,
[
"project_id"
,
"iid"
],
name:
"index_deployments_on_project_id_and_iid"
,
unique:
true
,
using: :btree
add_index
"deployments"
,
[
"project_id"
],
name:
"index_deployments_on_project_id"
,
using: :btree
create_table
"emails"
,
force: :cascade
do
|
t
|
t
.
integer
"user_id"
,
null:
false
...
...
@@ -570,7 +566,6 @@ ActiveRecord::Schema.define(version: 20161128161412) do
end
add_index
"labels"
,
[
"group_id"
,
"project_id"
,
"title"
],
name:
"index_labels_on_group_id_and_project_id_and_title"
,
unique:
true
,
using: :btree
add_index
"labels"
,
[
"group_id"
],
name:
"index_labels_on_group_id"
,
using: :btree
create_table
"lfs_objects"
,
force: :cascade
do
|
t
|
t
.
string
"oid"
,
null:
false
...
...
@@ -601,7 +596,6 @@ ActiveRecord::Schema.define(version: 20161128161412) do
end
add_index
"lists"
,
[
"board_id"
,
"label_id"
],
name:
"index_lists_on_board_id_and_label_id"
,
unique:
true
,
using: :btree
add_index
"lists"
,
[
"board_id"
],
name:
"index_lists_on_board_id"
,
using: :btree
add_index
"lists"
,
[
"label_id"
],
name:
"index_lists_on_label_id"
,
using: :btree
create_table
"members"
,
force: :cascade
do
|
t
|
...
...
@@ -727,7 +721,6 @@ ActiveRecord::Schema.define(version: 20161128161412) do
add_index
"milestones"
,
[
"description"
],
name:
"index_milestones_on_description_trigram"
,
using: :gin
,
opclasses:
{
"description"
=>
"gin_trgm_ops"
}
add_index
"milestones"
,
[
"due_date"
],
name:
"index_milestones_on_due_date"
,
using: :btree
add_index
"milestones"
,
[
"project_id"
,
"iid"
],
name:
"index_milestones_on_project_id_and_iid"
,
unique:
true
,
using: :btree
add_index
"milestones"
,
[
"project_id"
],
name:
"index_milestones_on_project_id"
,
using: :btree
add_index
"milestones"
,
[
"title"
],
name:
"index_milestones_on_title"
,
using: :btree
add_index
"milestones"
,
[
"title"
],
name:
"index_milestones_on_title_trigram"
,
using: :gin
,
opclasses:
{
"title"
=>
"gin_trgm_ops"
}
...
...
@@ -790,7 +783,6 @@ ActiveRecord::Schema.define(version: 20161128161412) do
add_index
"notes"
,
[
"noteable_id"
,
"noteable_type"
],
name:
"index_notes_on_noteable_id_and_noteable_type"
,
using: :btree
add_index
"notes"
,
[
"noteable_type"
],
name:
"index_notes_on_noteable_type"
,
using: :btree
add_index
"notes"
,
[
"project_id"
,
"noteable_type"
],
name:
"index_notes_on_project_id_and_noteable_type"
,
using: :btree
add_index
"notes"
,
[
"project_id"
],
name:
"index_notes_on_project_id"
,
using: :btree
add_index
"notes"
,
[
"updated_at"
],
name:
"index_notes_on_updated_at"
,
using: :btree
create_table
"notification_settings"
,
force: :cascade
do
|
t
|
...
...
@@ -1243,7 +1235,6 @@ ActiveRecord::Schema.define(version: 20161128161412) do
add_index
"users_star_projects"
,
[
"project_id"
],
name:
"index_users_star_projects_on_project_id"
,
using: :btree
add_index
"users_star_projects"
,
[
"user_id"
,
"project_id"
],
name:
"index_users_star_projects_on_user_id_and_project_id"
,
unique:
true
,
using: :btree
add_index
"users_star_projects"
,
[
"user_id"
],
name:
"index_users_star_projects_on_user_id"
,
using: :btree
create_table
"web_hooks"
,
force: :cascade
do
|
t
|
t
.
string
"url"
,
limit:
2000
...
...
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