Search Postgresql Archives

Re: question on most efficient way to increment a column

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The simple update is one I considered, but I think if I put it into a stored procedure it should run faster



From: Albe Laurenz <laurenz.albe@xxxxxxxxxx>;
To: Tyson Maly <tvmaly@xxxxxxxxx>; pgsql-general@xxxxxxxxxxxxxx <pgsql-general@xxxxxxxxxxxxxx>;
Subject: Re: question on most efficient way to increment a column
Sent: Wed, May 8, 2013 2:02:58 PM

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


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux