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

Re: How to add constraints without validating data.

From: Robert Voinea <robert(dot)voinea(at)topex(dot)ro>
To: pgsql-admin(at)postgresql(dot)org
Cc: Nilesh Govindarajan <lists(at)itech7(dot)com>, Iñigo Martinez Lasala <imartinez(at)vectorsf(dot)com>, Amit jain <amitjain(at)synechron(dot)com>
Subject: Re: How to add constraints without validating data.
Date: 2010-05-28 05:44:52
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-admin
Why don't you use a partition?

Create another table that inherits from the table and add your new constraints 
to the new table.

On Thursday 27 May 2010 19:32:33 Nilesh Govindarajan wrote:
> On Thu, May 27, 2010 at 9:49 PM, Iñigo Martinez Lasala
> <imartinez(at)vectorsf(dot)com> wrote:
> > Constraints are special triggers, but triggers anyway.
> > 
> > So, If you truncate the table, create the contraint and then restore with
> > triggers disabled, it could be faster that create the contraint and wait
> > until it checks all table data... or not... :)
> > 
> > How would disabling triggers help that ? He just wants to add
> > constraints without loss of data. I don't think he has any triggers.
> I agree constraints are triggers. But as far as I know, truncating
> table doesn't disable the constraints.
> Its same as deleteing all rows and then altering the table.
> In that manner, even my solution would be appropriate because it
> creates a duplicate table with the constraints.
> Whatever be the method, I don't think its possible to avoid the
> constraints. Correct me if I'm wrong.

Robert Voinea <robert (dot) voinea (at) topex (dot) ro>
Software Developer
Phone: +40 21 408 38 00 / ext. 343
Fax: +40 21 408 38 08
Local time: GMT+2

In response to

pgsql-admin by date

Next:From: Iñigo Martinez LasalaDate: 2010-05-28 07:43:04
Subject: Re: About "Context-switch storm" problem
Previous:From: Tom LaneDate: 2010-05-28 00:42:09
Subject: Re: List traffic

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