Skip site navigation (1) Skip section navigation (2)

Re: Incr/Decr Integer

From: Richard Huxton <dev(at)archonet(dot)com>
To: William Scott Jordan <wsjordan(at)brownpapertickets(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Incr/Decr Integer
Date: 2009-07-16 18:46:15
Message-ID: 4A5F7577.4000306@archonet.com (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-performance
William Scott Jordan wrote:
> Hey all!
> 
> Is there a better way to increase or decrease the value of an integer 
> than doing something like:

> UPDATE the_table SET the_int = the_int + 1 WHERE the_id = 123 ;

No.

> We seem to be getting a lot of deadlocks using this method under heavy 
> load.  Just wondering if we should be doing something different.

You can't get deadlocks with that - it only references one table.

What is the purpose of this query - how are you using it?

-- 
   Richard Huxton
   Archonet Ltd

In response to

pgsql-performance by date

Next:From: Kevin GrittnerDate: 2009-07-16 19:15:33
Subject: Re: cluster index on a table
Previous:From: Justin PittsDate: 2009-07-16 18:35:50
Subject: Re: cluster index on a table

pgsql-general by date

Next:From: Bruce MomjianDate: 2009-07-16 18:58:20
Subject: Re: [GENERAL] pg_migrator not setting values of sequences?
Previous:From: Andres FreundDate: 2009-07-16 18:30:56
Subject: Re: [PERFORM] Incr/Decr Integer

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group