Skip to content

postgres/foreign-key-indexes

Checks that an index, a primary key, or a unique key leads with every foreign key column.

Part of the postgres configuration, at the recommended level. It runs at the commit stage, once per scope. gspot runs this check itself.

Deleting a parent row scans the whole child table when the foreign key has no index.

Create an index that starts with the foreign key column.

A foreign key on orders.customer_id without an index starting with that column reports a missing index. Add CREATE INDEX orders_customer_id_idx ON orders (customer_id); in the migration set.

Turn it off for some files, with a reason:

gspot ignore postgres/foreign-key-indexes --paths "<glob>" --reason "<why>"