Re: How are foreign key constraints built?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: How are foreign key constraints built?
Дата
Msg-id 5442.1106506901@sss.pgh.pa.us
обсуждение исходный текст
Ответ на How are foreign key constraints built?  (Wes <wespvp@syntegra.com>)
Ответы Re: How are foreign key constraints built?  ("Jim C. Nasby" <decibel@decibel.org>)
Re: How are foreign key constraints built?  (Wes <wespvp@syntegra.com>)
Список pgsql-general
Wes <wespvp@syntegra.com> writes:
> There's no problem here, I'd just like to understand what it is doing.

Either a hash or merge join between the two tables, to verify that all
the keys in the referencing table exist in the referenced table.  The
intermediate data is evidently spilling to disk.

> I expected adding the foreign key constraint would just use the existing
> indexes to verify the database is currently consistent.

People have this weird notion that an index-based plan is always faster
than anything else.  If you like you can try the operation with "set
enable_seqscan = off", but I bet it will take longer.

            regards, tom lane

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

Предыдущее
От: Wes
Дата:
Сообщение: How are foreign key constraints built?
Следующее
От: Jarkko Elfving
Дата:
Сообщение: Re: Dead-end in PostgreSQL 8.0 fresh installation (while