requireConcurrentReindex
Diagnostic Category: lint/safety/requireConcurrentReindex
Since: vnext
Note
This rule is recommended. A diagnostic error will appear when linting your code.
Sources:
- Inspired from: pgfence/reindex-non-concurrent
Description
REINDEX without CONCURRENTLY acquires an ACCESS EXCLUSIVE lock on the table.
This blocks all reads and writes until the reindex completes. Use REINDEX CONCURRENTLY
to rebuild the index without blocking concurrent operations.
Examples
Invalid
reindex index my_index;
code-block.sql:1:1 lint/safety/requireConcurrentReindex ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! REINDEX without CONCURRENTLY blocks all table access.
> 1 │ reindex index my_index;
│ ^^^^^^^^^^^^^^^^^^^^^^^
2 │
i Use REINDEX CONCURRENTLY to rebuild the index without blocking reads and writes.
Valid
reindex index concurrently my_index;
How to configure
{
"linter": {
"rules": {
"safety": {
"requireConcurrentReindex": "error"
}
}
}
}