Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres: How to create index concurrently using liquibase

Looking at the liquibase documention http://www.liquibase.org/documentation/changes/create_index.html, CIC is not possible with create index, as liquibase doesn't have a tag to specify concurrent option.

Is there a way to create index concurrently with liquibase?

like image 454
user4988095 Avatar asked Mar 15 '18 13:03

user4988095


People also ask

What is CREATE INDEX concurrently?

What is CREATE INDEX concurrently? In a concurrent index build, the index is actually entered into the system catalogs in one transaction, then two table scans occur in two more transactions. Before each table scan, the index build must wait for existing transactions that have modified the table to terminate.

Why would you choose to build an index concurrently in Postgres?

PostgreSQL provides the facility of creating index concurrently to avoid blocking and updating any table through the read and write commands.

Does Liquibase work with PostgreSQL?

To use Liquibase and PostgreSQL, you need the JDBC driver JAR file (Maven download). The latest version of Liquibase has a pre-installed driver for this database in the liquibase/internal/lib directory.

Does Postgres create indexes automatically?

PostgreSQL automatically creates a unique index when a unique constraint or primary key is defined for a table. The index covers the columns that make up the primary key or unique constraint (a multicolumn index, if appropriate), and is the mechanism that enforces the constraint.


1 Answers

You can specify runInTransaction as false to create the index concurrently.

like image 106
TheDude Avatar answered Dec 04 '22 19:12

TheDude