E
E
evilelf2018-11-20 12:55:59
PostgreSQL
evilelf, 2018-11-20 12:55:59

Is an index automatically created when creating a foreign key in PostgreSQL 10?

Hello.
Is an index automatically created when creating a foreign key in PostgreSQL 10?
Or does it need to be created manually?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2018-11-21
@evilelf

No, it is not created. On the table to which the FK index refers, a unique one must already be created, on the table that refers to the presence of the index is not checked in any way and is not even required. It is only necessary to understand that FK - for each row triggers and without an index there will be N seqscan tables.
Usually the index is created manually. Sometimes intentionally not created.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question