gitlab-org--gitlab-foss/spec/lib/gitlab/database
Yorick Peterse a97dcc077c
Add method for creating foreign keys concurrently
This method allows one to create foreign keys without blocking access to
the source table, but only on PostgreSQL.

When creating a regular foreign key the "ALTER TABLE" statement used for
this won't return until all data has been validated. This statement in
turn will acquire a lock on the source table. As a result this lock can
be held for quite a long amount of time, depending on the number of rows
and system load.

By breaking up the foreign key creation process in two steps (creation,
and validation) we can reduce the amount of locking to a minimum.
Locking is still necessary for the "ALTER TABLE" statement that adds the
constraint, but this is a fast process and so will only block access for
a few milliseconds.
2017-02-10 21:51:09 +01:00
..
migration_helpers_spec.rb Add method for creating foreign keys concurrently 2017-02-10 21:51:09 +01:00