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
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-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

Browse pgsql-general by date

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

Browse pgsql-performance by date

  From Date Subject
Next Message Kevin Grittner 2009-07-16 19:15:33 Re: cluster index on a table
Previous Message Justin Pitts 2009-07-16 18:35:50 Re: cluster index on a table