Re: Update violating constraint - Mailing list pgsql-general

From Richard Broersma Jr
Subject Re: Update violating constraint
Date
Msg-id 194540.41655.qm@web31810.mail.mud.yahoo.com
Whole thread Raw
In response to Re: Update violating constraint  (Naz Gassiep <naz@mira.net>)
Responses Re: Update violating constraint
List pgsql-general
> > update foo
> > set field = -1 * (field + 1);
> > update foo
> > set field = -1 * field
> > where field < 0;
> >
> Yes, in fact I actually use option one already in the handling of sql
> trees, so I'm annoyed with myself for not figuring that out. I don't
> know why you'd ever use your second option ever, as it virtually
> guarantees problems at a random point in your DB's growth.


If you are updating a large portion of your tree, you will probably want to throw in a vacuum in
between the two updates.  This should reduce the bloat caused by dead tuples in both your index
and table.

Regards,
Richard Broersma Jr.

pgsql-general by date:

Previous
From: Stephen Harris
Date:
Subject: Re: Have I b0rked something? Slow comparisons on "where x in (...)"
Next
From: Csaba Nagy
Date:
Subject: Re: Update violating constraint