Re: atomic multi-threaded upsert

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Mikhail V(dot) Puzanov" <misha(dot)puzanov(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: atomic multi-threaded upsert
Date: 2010-11-24 21:21:10
Message-ID: 21822.1290633670@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Mikhail V. Puzanov" <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()?

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message John Fabiani 2010-11-25 00:07:43 insert from a select
Previous Message Louis-David Mitterrand 2010-11-24 20:53:16 Re: "compressing" consecutive values into one