Why this matters
Non-concurrent `REINDEX TABLE` takes a `SHARE` lock that blocks writers for the duration; `REINDEX INDEX` takes `ACCESS EXCLUSIVE`. PG ≥ 12 introduced `REINDEX (...) CONCURRENTLY`, which builds a parallel index and swaps without blocking writers. The `never` style is for migration tools that wrap each step in `BEGIN`/`COMMIT` — `CONCURRENTLY` cannot run inside a transaction.
Examples
Incorrect
REINDEX TABLE users;Correct
REINDEX TABLE CONCURRENTLY users;Configure it
// eslint.config.js
import postgresql from "eslint-plugin-postgresql";
export default [
{
files: ["**/*.sql"],
languageOptions: {
parser: postgresql.configs.recommended.languageOptions.parser,
},
plugins: { postgresql },
rules: {
"postgresql/consistent-reindex-concurrently": [
"warn",
{
style: "always",
},
],
},
},
]; Options
Edit the SQL — only consistent-reindex-concurrently is enabled.
Pre-filled with the first incorrect example. Toggle off in the rule shelf to see how the diagnostic disappears.
Diagnostics
No issues found.
2 rules enabled.
Rule under test
consistent-reindex-concurrently — plus no-syntax-error as a safety net.