Re: question on most efficient way to increment a column - Mailing list pgsql-general

From Albe Laurenz
Subject Re: question on most efficient way to increment a column
Date
Msg-id A737B7A37273E048B164557ADEF4A58B05818F07@ntex2010a.host.magwien.gv.at
Whole thread Raw
In response to question on most efficient way to increment a column  (Tyson Maly <tvmaly@yahoo.com>)
List pgsql-general
Tyson Maly wrote:
> If I have a simple table with an id as a primary key that is a serial column and a column to keep
> track of a total_count for a particular id, what method would provide the fastest way to increment the
> total_count in the shortest amount of time and minimize any locking?
>
> id  serial
> total_count integer

UPDATE tablename SET total_count=total_count+1 WHERE id=42;

Yours,
Laurenz Albe


pgsql-general by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: question on most efficient way to increment a column
Next
From: Tom Lane
Date:
Subject: Re: Does it make sense to break a large query into separate functions?