Adding an index without a lag (PostgreSQL)
See Building Indexes Concurrently in PostgreSQL documentation.
CONCURRENTLY option of CREATE INDEX solves the problem in an easy way. Just add it to CREATE INDEX.
Be aware that while CONCURRENTLY option avoids lags, it does slow down building the index and that CREATE INDEX with CONCURRENTLY cannot be used in a transaction.