Re: Foreign key wierdness

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Dave Page" <dpage(at)vale-housing(dot)co(dot)uk>
Cc: "PostgreSQL Hackers Mailing List" <pgsql-hackers(at)postgresql(dot)org>, "Didier Moens" <moensd(at)xs4all(dot)be>
Subject: Re: Foreign key wierdness
Date: 2003-01-20 15:27:38
Message-ID: 3113.1043076458@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Dave Page" <dpage(at)vale-housing(dot)co(dot)uk> writes:
> A pgAdmin user has noticed that Foreign Keys take significantly longer
> to create when migrating a database in pgAdmin in v1.4.12 than in
> v1.4.2.

The only reason ADD FOREIGN KEY would take a long time is if
(a) it has to wait awhile to get exclusive lock on either
the referencing or referenced table; and/or
(b) it takes a long time to verify that the existing entries
in the referencing table all have matches in the referenced table.
(that's the behind-the-scenes query you see)

I'm betting that the table was busy, or there was a lot more data
present in the one case, or you hadn't ever vacuumed/analyzed one or
both tables and so a bad plan was chosen for the verification query.
The schema reference is definitely not the issue.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dave Page 2003-01-20 15:47:51 Re: Foreign key wierdness
Previous Message Adrian 'Dagurashibanipal' von Bidder 2003-01-20 10:47:53 Re: Options for growth