Skip site navigation (1) Skip section navigation (2)

Re: Short-circuiting FK check for a newly-added field

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Reece Hart <reece(at)harts(dot)net>
Cc: Decibel! <decibel(at)decibel(dot)org>, Postgres List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Short-circuiting FK check for a newly-added field
Date: 2008-05-23 22:48:59
Message-ID: 20080523224859.GF23016@alvh.no-ip.org (view raw or flat)
Thread:
Lists: pgsql-general
Reece Hart wrote:
> On Tue, May 20, 2008 at 02:25:15PM -0400, Decibel! wrote:
> > I need to add a field to a fairly large table. In the same alter statement 
> > I'd like to add a FK constraint on that new field. Is there any way to 
> > avoid the check of the table that the database is doing right now? The 
> > check is pointless because the newly added field is nothing but NULLs.
> >   
> I don't see the problem. FK constraints don't fire on NULL values. I
> think you might be imagining that a problem exists when it doesn't.

The problem is that it does a table scan only to find that all values
are NULL, which is pretty pointless.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

pgsql-general by date

Next:From: Teodor SigaevDate: 2008-05-24 03:57:16
Subject: Re: Fragments in tsearch2 headline
Previous:From: Howard ColeDate: 2008-05-23 22:28:15
Subject: Re: Error: Could not open relation...

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group