All rules

Performance

postgresql/consistent-reindex-concurrently

Enforce a consistent stance on `CONCURRENTLY` for `REINDEX`.

  • Type problem
  • Recommended warn
  • Fixable no

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

Incorrect
REINDEX TABLE users;

Correct

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

style "always" | "never" default: "always"
`always` (default) requires `CONCURRENTLY`. `never` forbids it so each `REINDEX` can run inside a migration transaction.
Try this rule

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.

0 errors 0 warnings parse 0ms · rules 0ms
Diagnostics

No issues found.

2 rules enabled.

Rule under test consistent-reindex-concurrently — plus no-syntax-error as a safety net.
eslint-plugin-postgresql

An ESLint plugin that lints .sql files with real PostgreSQL grammar and a curated set of best-practice rules.

© 2026 eslint-plugin-postgresql contributors Built on libpg-query · PostgreSQL 17