Re: [GENERAL] Avoiding a deadlock

2013-03-12 Thread Albe Laurenz
Paul Jungwirth wrote: >> Out of curiosity: any reason the ORDER BY should be in the subquery? It >> seems like it ought to be in > the UPDATE (if that's allowed). > > Hmm, it's not allowed. :-) It's still surprising that you can guarantee the > order of a multi-row > UPDATE by ordering a subquer

Re: [GENERAL] Avoiding a deadlock

2013-03-11 Thread Paul Jungwirth
> Out of curiosity: any reason the ORDER BY should be in the subquery? It seems like it ought to be in the UPDATE (if that's allowed). Hmm, it's not allowed. :-) It's still surprising that you can guarantee the order of a multi-row UPDATE by ordering a subquery. Paul --

Re: [GENERAL] Avoiding a deadlock

2013-03-11 Thread Paul Jungwirth
> 2) All transactions modify table rows in the same order, e.g. ascending "id". >With the big update you can do that by putting an "ORDER BY tg2.id" into >the subquery, and with the "little transactions" you'll have to make sure >that rows are updated in ascending "id" order. I agree t

Re: [GENERAL] Avoiding a deadlock

2013-03-11 Thread Albe Laurenz
Alban Hertroys wrote: > All the suggestions thus far only reduce the window in which a dead lock can > occur. Where do you see a window for deadlocks with my suggestions? Yours, Laurenz Albe -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscrip

Re: [GENERAL] Avoiding a deadlock

2013-03-11 Thread Alban Hertroys
On 11 March 2013 13:01, Chris Curvey wrote: > On Sat, Mar 9, 2013 at 4:20 PM, Paul Jungwirth < > p...@illuminatedcomputing.com> wrote: > >> I have a long-running multi-row UPDATE that is deadlocking with a >> single-row UPDATE: >> >> 2013-03-09 11:07:51 CST ERROR: deadlock detected >> 2013-03-09

Re: [GENERAL] Avoiding a deadlock

2013-03-11 Thread Chris Curvey
On Sat, Mar 9, 2013 at 4:20 PM, Paul Jungwirth wrote: > I have a long-running multi-row UPDATE that is deadlocking with a > single-row UPDATE: > > 2013-03-09 11:07:51 CST ERROR: deadlock detected > 2013-03-09 11:07:51 CST DETAIL: Process 18851 waits for ShareLock on > transaction 10307138; block

Re: [GENERAL] Avoiding a deadlock

2013-03-11 Thread Albe Laurenz
Paul Jungwirth wrote: > I have a long-running multi-row UPDATE that is deadlocking with a single-row > UPDATE: > > 2013-03-09 11:07:51 CST ERROR: deadlock detected > 2013-03-09 11:07:51 CST DETAIL: Process 18851 waits for ShareLock on > transaction 10307138; blocked by > process 24203. >