[12.x] Online (concurrently) index creation for PostgreSQL and SqlServer #56625
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
By default Postgresql and SqlServer create index using write lock (exclusive lock) on table. This makes application unusable durng migration, if index creation is long (big table), leading to downtime wich is not suitable in production.
Currentrly creating indexex concurrently is possible only with DB::statement method. This PR adds ability to use it online() method in index definition.
Tried different names for IndexDefinition method (withoutLock, noLock, concurrently). Selected "online", as it's most widely used terminology. See https://mariadb.com/docs/server/server-usage/storage-engines/innodb/innodb-online-ddl/innodb-online-ddl-overview , https://learn.microsoft.com/en-us/sql/relational-databases/indexes/perform-index-operations-online?view=sql-server-ver16 .
Currently postgresql uses add constraint command for unique indexes, which does not support Concurently option. For such case two commands are used (create index and add constraint), as described in https://www.postgresql.org/docs/17/sql-altertable.html#SQL-ALTERTABLE-DESC-ADD-TABLE-CONSTRAINT-USING-INDEX