Re: atomic multi-threaded upsert - Mailing list pgsql-sql

From Tom Lane
Subject Re: atomic multi-threaded upsert
Date
Msg-id 21822.1290633670@sss.pgh.pa.us
Whole thread Raw
In response to atomic multi-threaded upsert  ("Mikhail V. Puzanov" <misha.puzanov@gmail.com>)
Responses Re: atomic multi-threaded upsert  (MIkhail Puzanov <misha.puzanov@gmail.com>)
List pgsql-sql
"Mikhail V. Puzanov" <misha.puzanov@gmail.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


pgsql-sql by date:

Previous
From: Louis-David Mitterrand
Date:
Subject: Re: "compressing" consecutive values into one
Next
From: John Fabiani
Date:
Subject: insert from a select