Re: How are foreign key constraints built?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Wes <wespvp(at)syntegra(dot)com>
Cc: Postgresql-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: How are foreign key constraints built?
Date: 2005-01-23 19:01:41
Message-ID: 5442.1106506901@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Wes <wespvp(at)syntegra(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jarkko Elfving 2005-01-23 20:09:11 Re: Dead-end in PostgreSQL 8.0 fresh installation (while
Previous Message Wes 2005-01-23 18:41:58 How are foreign key constraints built?