Re: Foreign key wierdness - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Foreign key wierdness
Date
Msg-id 3113.1043076458@sss.pgh.pa.us
Whole thread Raw
In response to Foreign key wierdness  ("Dave Page" <dpage@vale-housing.co.uk>)
List pgsql-hackers
"Dave Page" <dpage@vale-housing.co.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
referencedtable.   (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


pgsql-hackers by date:

Previous
From: Adrian 'Dagurashibanipal' von Bidder
Date:
Subject: Re: Options for growth
Next
From: "Dave Page"
Date:
Subject: Re: Foreign key wierdness