Re: Creating a foreign key

Поиск
Список
Период
Сортировка
От PFC
Тема Re: Creating a foreign key
Дата
Msg-id op.uaupyxsecigqcu@apollo13.peufeu.com
обсуждение исходный текст
Ответ на Creating a foreign key  ("Campbell, Lance" <lance@uiuc.edu>)
Список pgsql-performance
> When you create a foreign key to a table is there an index that is
> created on the foreign key automatically?

    No, Postgres doesn't do it for you, because if you create (ref_id)
references table.id, you will perhaps create an index on (ref_id, date)
which would then fill the purpose (and other purposes), or perhaps your
table will have 10 rows (but postgres doesnt' know that when you create
it) and having an index would be useless, or your table could have many
rows but only a few distinct referenced values, in which case again the
index would only slow things down.
    PG does not presume to know better than yourself what you're gonna do
with your data ;)
    UNIQUE and PRIMARY KEY do create UNIQUE INDEXes, of course.

В списке pgsql-performance по дате отправления:

Предыдущее
От: Asche
Дата:
Сообщение: Re: Creating indexes
Следующее
От: PFC
Дата:
Сообщение: Re: Creating indexes