From: | "Mikhail V(dot) Puzanov" <misha(dot)puzanov(at)gmail(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: atomic multi-threaded upsert |
Date: | 2010-11-27 15:08:39 |
Message-ID: | 4CF11EF7.4020605@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On 25.11.2010 12:51, MIkhail Puzanov wrote:
>
>
> 2010/11/25 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us <mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us>>
>
> "Mikhail V. Puzanov" <misha(dot)puzanov(at)gmail(dot)com
> <mailto:misha(dot)puzanov(at)gmail(dot)com>> writes:
> > -- increment and get the counter if exists
> > UPDATE sequences SET counter = counter + 1
> > WHERE section = 'testSection' AND name = 'testKey'
> > RETURNING counter;
>
> Seems that what you have here is a bad manual implementation of a
> sequence. Why don't you use a real sequence object and nextval()?
>
>
>
> Well, if I use the real sequence, I'll need unpredictable number of them
> and will have to store mapping (section, name)->sequenceName, and
> also will have to create those sequences dynamically the similar way.
>
Finally the problem solved with application level locks (that works for
only
one application server, but suits our needs for now).
This also works
http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE
but we need some more or less cross-DBMS approach.
From | Date | Subject | |
---|---|---|---|
Next Message | Stefan Becker | 2010-11-28 23:30:47 | Is there a solution for "SELECT OR INSERT" |
Previous Message | ndias | 2010-11-26 17:28:48 | Re: Insert row in 1.10.1 and 1.10.3 |