DB Downtime while indexing a existing record postgres

I have an Elixir application that uses Postgres Db and I want to index a field with a row count of 54K. There are few NULL values as well.

I use Ecto.Migration

def change do
   create(index(:rules_engine_test_cases, [:rule_set_version_id]))
end

Will there be any downtime in this case?

No downtime but some queries might be delayed until the indexing finishes.

However, PostgreSQL supports CREATE INDEX CONCURRENTLY for a long time now (at least from 9.6 and on): PostgreSQL: Documentation: 13: CREATE INDEX

Check out the docs of Migration.index – there’s a :concurrently option available.

2 Likes

Relax, 54K rows are not a whole lot. I bet it finish in seconds.

2 Likes

More like milliseconds.

2 Likes