Foreign key indexes

PostgreSQL automatically creates an index for a primary key or a uniqueness constraint, but not for a foreign key. Indexing foreign key columns speeds up joins and integrity checks when the referenced row is deleted or modified.

Example

CREATE INDEX idx_commandes_client ON commandes (client_id);

Related concepts

The whole glossary