BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
3f0054a8
Commit
3f0054a8
authored
Apr 18, 2017
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unique index for note_id to system note metadata table
In issue 1, the sequential scan was taking 250+ ms.
parent
a9da3743
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
1 deletion
+24
-1
sh-add-index-to-system-note-metadata.yml
...elogs/unreleased/sh-add-index-to-system-note-metadata.yml
+4
-0
20170419001229_add_index_to_system_note_metadata.rb
...grate/20170419001229_add_index_to_system_note_metadata.rb
+17
-0
schema.rb
db/schema.rb
+3
-1
No files found.
changelogs/unreleased/sh-add-index-to-system-note-metadata.yml
0 → 100644
View file @
3f0054a8
---
title
:
Add unique index for notes_id to system note metadata table
merge_request
:
author
:
db/migrate/20170419001229_add_index_to_system_note_metadata.rb
0 → 100644
View file @
3f0054a8
class
AddIndexToSystemNoteMetadata
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME
=
false
disable_ddl_transaction!
def
up
# MySQL automatically creates an index on a foreign-key constraint; PostgreSQL does not
add_concurrent_index
:system_note_metadata
,
:note_id
,
unique:
true
if
Gitlab
::
Database
.
postgresql?
end
def
down
remove_concurrent_index
:system_note_metadata
,
:note_id
,
unique:
true
if
Gitlab
::
Database
.
postgresql?
end
end
db/schema.rb
View file @
3f0054a8
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2017041
8103908
)
do
ActiveRecord
::
Schema
.
define
(
version:
2017041
9001229
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -1140,6 +1140,8 @@ ActiveRecord::Schema.define(version: 20170418103908) do
t
.
datetime
"updated_at"
,
null:
false
end
add_index
"system_note_metadata"
,
[
"note_id"
],
name:
"index_system_note_metadata_on_note_id"
,
unique:
true
,
using: :btree
create_table
"taggings"
,
force: :cascade
do
|
t
|
t
.
integer
"tag_id"
t
.
integer
"taggable_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