Skip to content

adlacruzes/check-fk-missing-index

Repository files navigation

Check foreign keys missing index

node-current GitHub package.json version GitHub Workflow Status (with branch)

Check foreign keys missing index in Postgres

Why?

PostgreSQL automatically creates indexes on primary keys and unique constraints, but not on foreign keys.

So I created a command to find the columns that maybe are in need of an index. It's up to you.

Usage

npx check-fk-missing-index
Usage: check-fk-missing-index [options]

Options:
  -V, --version          output the version number
  --format <format>      Output format (choices: "table", "json", "minimal", default: "table")
  --host <host>          database server host or socket directory (default: "localhost")
  --port <port>          database server port (default: "5432")
  --username <username>  database user name (default: "postgres")
  --database <dbname>    database name to connect to (default: "postgres")
  --password <password>  database password (default: "")
  --no-fail              return code 0 on exit
  -h, --help             display help for command