diff options
author | Shinya Maeda <shinya@gitlab.com> | 2019-05-23 12:45:52 +0000 |
---|---|---|
committer | Marcia Ramos <marcia@gitlab.com> | 2019-05-23 12:45:52 +0000 |
commit | ff14b58dc5e0349567f903b23966a808f9d3f8cb (patch) | |
tree | 6679101246050cefe37c77313afdeba161a6298a /doc/development | |
parent | 26d608cb60d1fbc724cfbf9d559188be39cd11e5 (diff) | |
download | gitlab-ce-ff14b58dc5e0349567f903b23966a808f9d3f8cb.tar.gz |
Add note for index requirement with FK constraint
Update migration_style_guide.md
Diffstat (limited to 'doc/development')
-rw-r--r-- | doc/development/migration_style_guide.md | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/doc/development/migration_style_guide.md b/doc/development/migration_style_guide.md index 0c326eeb851..9b26f691b55 100644 --- a/doc/development/migration_style_guide.md +++ b/doc/development/migration_style_guide.md @@ -186,7 +186,11 @@ end When adding a foreign-key constraint to either an existing or new column remember to also add a index on the column. -This is _required_ for all foreign-keys. +This is **required** for all foreign-keys, e.g., to support efficient cascading +deleting: when a lot of rows in a table get deleted, the referenced records need +to be deleted too. The database has to look for corresponding records in the +referenced table. Without an index, this will result in a sequential scan on the +table which can take a long time. Here's an example where we add a new column with a foreign key constraint. Note it includes `index: true` to create an index for it. |