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
680ebf44
Commit
680ebf44
authored
Dec 20, 2017
by
Greg Stark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add index on namespaces lower(name) for UsersController#exists
parent
82e31ee4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
1 deletion
+38
-1
changelogs/unreleased/index-namespaces-lower-name.yml
changelogs/unreleased/index-namespaces-lower-name.yml
+5
-0
db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb
...rate/20171220191323_add_index_on_namespaces_lower_name.rb
+30
-0
db/schema.rb
db/schema.rb
+1
-1
lib/tasks/migrate/setup_postgresql.rake
lib/tasks/migrate/setup_postgresql.rake
+2
-0
No files found.
changelogs/unreleased/index-namespaces-lower-name.yml
0 → 100644
View file @
680ebf44
---
title
:
Add index on namespaces lower(name) for UsersController#exists
merge_request
:
author
:
type
:
performance
db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb
0 → 100644
View file @
680ebf44
class
AddIndexOnNamespacesLowerName
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
INDEX_NAME
=
'index_on_namespaces_lower_name'
disable_ddl_transaction!
def
up
return
unless
Gitlab
::
Database
.
postgresql?
disable_statement_timeout
if
Gitlab
::
Database
.
version
.
to_f
>=
9.5
# Allow us to hot-patch the index manually ahead of the migration
execute
"CREATE INDEX CONCURRENTLY IF NOT EXISTS
#{
INDEX_NAME
}
ON namespaces (lower(name));"
else
execute
"CREATE INDEX CONCURRENTLY
#{
INDEX_NAME
}
ON namespaces (lower(name));"
end
end
def
down
return
unless
Gitlab
::
Database
.
postgresql?
disable_statement_timeout
if
Gitlab
::
Database
.
version
.
to_f
>=
9.2
execute
"DROP INDEX CONCURRENTLY IF EXISTS
#{
INDEX_NAME
}
;"
else
execute
"DROP INDEX IF EXISTS
#{
INDEX_NAME
}
;"
end
end
end
db/schema.rb
View file @
680ebf44
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201712
19121201
)
do
ActiveRecord
::
Schema
.
define
(
version:
201712
20191323
)
do
# These are extensions that must be enabled in order to support this database
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
enable_extension
"plpgsql"
...
...
lib/tasks/migrate/setup_postgresql.rake
View file @
680ebf44
...
@@ -6,6 +6,7 @@ require Rails.root.join('db/migrate/20161212142807_add_lower_path_index_to_route
...
@@ -6,6 +6,7 @@ require Rails.root.join('db/migrate/20161212142807_add_lower_path_index_to_route
require
Rails
.
root
.
join
(
'db/migrate/20170317203554_index_routes_path_for_like'
)
require
Rails
.
root
.
join
(
'db/migrate/20170317203554_index_routes_path_for_like'
)
require
Rails
.
root
.
join
(
'db/migrate/20170724214302_add_lower_path_index_to_redirect_routes'
)
require
Rails
.
root
.
join
(
'db/migrate/20170724214302_add_lower_path_index_to_redirect_routes'
)
require
Rails
.
root
.
join
(
'db/migrate/20170503185032_index_redirect_routes_path_for_like'
)
require
Rails
.
root
.
join
(
'db/migrate/20170503185032_index_redirect_routes_path_for_like'
)
require
Rails
.
root
.
join
(
'db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb'
)
desc
'GitLab | Sets up PostgreSQL'
desc
'GitLab | Sets up PostgreSQL'
task
setup_postgresql: :environment
do
task
setup_postgresql: :environment
do
...
@@ -15,4 +16,5 @@ task setup_postgresql: :environment do
...
@@ -15,4 +16,5 @@ task setup_postgresql: :environment do
IndexRoutesPathForLike
.
new
.
up
IndexRoutesPathForLike
.
new
.
up
AddLowerPathIndexToRedirectRoutes
.
new
.
up
AddLowerPathIndexToRedirectRoutes
.
new
.
up
IndexRedirectRoutesPathForLike
.
new
.
up
IndexRedirectRoutesPathForLike
.
new
.
up
AddIndexOnNamespacesLowerName
.
new
.
up
end
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