> > 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.