03417456f0
By using a JOIN we can remove the need for using 2 separate queries to find a project by its namespace. Combined with an index (only needed for PostgreSQL) this reduces the query time from ~245 ms (~520 ms for the first call) down to roughly 10 ms (~15 ms for the first call).
17 lines
556 B
Ruby
17 lines
556 B
Ruby
class NamespacesProjectsPathLowerIndexes < ActiveRecord::Migration
|
|
disable_ddl_transaction!
|
|
|
|
def up
|
|
return unless Gitlab::Database.postgresql?
|
|
|
|
execute 'CREATE INDEX CONCURRENTLY index_on_namespaces_lower_path ON namespaces (LOWER(path));'
|
|
execute 'CREATE INDEX CONCURRENTLY index_on_projects_lower_path ON projects (LOWER(path));'
|
|
end
|
|
|
|
def down
|
|
return unless Gitlab::Database.postgresql?
|
|
|
|
remove_index :namespaces, name: :index_on_namespaces_lower_path
|
|
remove_index :projects, name: :index_on_projects_lower_path
|
|
end
|
|
end
|