Re: [SQL] changing multiple pk's in one update

2009-04-15 Thread Glenn Maynard
On Wed, Apr 15, 2009 at 8:43 AM, Jasen Betts wrote: > the update takes a long time too if it's updating all the rows. > and updating the index piecewise at the same time. > with the index extant I get from 20 (if the start and end ranges don't > overlap) and 28s (with , > to 28 seconds (maximum o

Re: [SQL] changing multiple pk's in one update

2009-04-15 Thread Jasen Betts
On 2009-04-13, Stuart McGraw wrote: > Jasen Betts wrote: >> I see no reason to keep the index (and its associated UNIQUE >> constraint) during the update, AFAICT all it does is slow the process >> down. > > Thanks for the suggestion. > > Unfortunately I am doing this key renumbering in > an inter

Re: [SQL] changing multiple pk's in one update

2009-04-14 Thread Steve Midgley
Date: Mon, 13 Apr 2009 17:09:49 -0400 From: Glenn Maynard To: pgsql-sql@postgresql.org Subject: Re: changing multiple pk's in one update Message-ID: (JMdict? I was playing with importing that into a DB a while back, but the attributes in that XML are such a pain--and then my email died while

Re: [SQL] changing multiple pk's in one update

2009-04-13 Thread Stuart McGraw
Glenn Maynard wrote: (JMdict? yup. ;-) I was playing with importing that into a DB a while back, but the attributes in that XML are such a pain--and then my email died while I was trying to get those changed, and I never picked it up again.) On Mon, Apr 13, 2009 at 1:20 PM, Stuart McGraw

Re: [SQL] changing multiple pk's in one update

2009-04-13 Thread Glenn Maynard
On Mon, Apr 13, 2009 at 5:43 PM, Richard Broersma wrote: > From what I've seen, this problem can affect both surrogate and > natural key designs.  In both cases, care must be taken to ensure that > an underling tuple hasn't been changed by any other clients before it > attempts to commit its chang

Re: [SQL] changing multiple pk's in one update

2009-04-13 Thread Richard Broersma
On Mon, Apr 13, 2009 at 2:32 PM, Glenn Maynard wrote: > If your senses are reordered by someone else, and > you operate on /10/3, you may suddenly find yourself viewing or > modifying (or deleting!) a different sense.  This could even happen > within the same transaction, if you're not very caref

Re: [SQL] changing multiple pk's in one update

2009-04-13 Thread Glenn Maynard
On Mon, Apr 13, 2009 at 5:18 PM, Richard Broersma wrote: >> Your PK is a composite of (entry, order)?  Won't your foreign keys >> elsewhere all break when you shift the order around? > > If there really are foreign keys, then an update will not be allowed > to shift a primary key unless the foreig

Re: [SQL] changing multiple pk's in one update

2009-04-13 Thread Richard Broersma
On Mon, Apr 13, 2009 at 2:09 PM, Glenn Maynard wrote: > Your PK is a composite of (entry, order)?  Won't your foreign keys > elsewhere all break when you shift the order around? If there really are foreign keys, then an update will not be allowed to shift a primary key unless the foreign key is

Re: [SQL] changing multiple pk's in one update

2009-04-13 Thread Glenn Maynard
(JMdict? I was playing with importing that into a DB a while back, but the attributes in that XML are such a pain--and then my email died while I was trying to get those changed, and I never picked it up again.) On Mon, Apr 13, 2009 at 1:20 PM, Stuart McGraw wrote: > 1 to the number of sentences

Re: [SQL] changing multiple pk's in one update

2009-04-13 Thread Stuart McGraw
Scott Marlowe wrote: 2009/4/7 Stuart McGraw : Hello all, I have a table with a primary key column that contains sequential numbers. Sometimes I need to shift them all up or down by a fixed amount. For example, if I have four rows with primary keys, 2, 3, 4, 5, I might want to shift them down

Re: [SQL] changing multiple pk's in one update

2009-04-13 Thread Richard Broersma
On Fri, Apr 10, 2009 at 11:20 AM, Scott Marlowe wrote: > Generally speaking, when you need to do this more than once or twice > in the lifetime of your data, there's something wrong with your data > model. True, but there are a few non-traditional data models that would benefit from this feature

Re: [SQL] changing multiple pk's in one update

2009-04-13 Thread Stuart McGraw
Jasen Betts wrote: On 2009-04-08, Stuart McGraw wrote: Hello all, I have a table with a primary key column that contains sequential numbers. Sometimes I need to shift them all up or down by a fixed amount. For example, if I have four rows with primary keys, 2, 3, 4, 5, I might want to shif

Re: [SQL] changing multiple pk's in one update

2009-04-10 Thread Scott Marlowe
2009/4/7 Stuart McGraw : > Hello all, > > I have a table with a primary key column > that contains sequential numbers. > > Sometimes I need to shift them all up or down > by a fixed amount.  For example, if I have > four rows with primary keys, 2, 3, 4, 5, I > might want to shift them down by 1 by

Re: [SQL] changing multiple pk's in one update

2009-04-10 Thread Jasen Betts
On 2009-04-08, Stuart McGraw wrote: > Hello all, > > I have a table with a primary key column > that contains sequential numbers. > > Sometimes I need to shift them all up or down > by a fixed amount. For example, if I have > four rows with primary keys, 2, 3, 4, 5, I > might want to shift them

[SQL] changing multiple pk's in one update

2009-04-07 Thread Stuart McGraw
Hello all, I have a table with a primary key column that contains sequential numbers. Sometimes I need to shift them all up or down by a fixed amount. For example, if I have four rows with primary keys, 2, 3, 4, 5, I might want to shift them down by 1 by doing: UPDATE mytable SET id=id-1 (