Table Lock during migration
- Index creation on a database table is a synchronous action that prevents INSERT, UPDATE, and DELETE operations until the full index is created
#
Solutions?- Postgresql way:
- TODO
- Rails Way:
Adding:
:algorithm => :concurrently
Migration:
- Output:
Why error?
- Because each migration is a transaction, and you can't run
concurrently
inside transaction.
- Because each migration is a transaction, and you can't run
Solution?
disable_ddl_transaction!
Migration
Output:
- Interesting enough, it took about the same time.
#
Resources:- Good article: https://semaphoreci.com/blog/2017/06/21/faster-rails-indexing-large-database-tables.html