Incr/Decr Integer

Поиск
Список
Период
Сортировка
Искать

Incr/Decr Integer

От:
William Scott Jordan <wsjordan@brownpapertickets.com>
Дата:
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 ;
---

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

Thanks!

-William

Re: Incr/Decr Integer

От:
Richard Huxton <dev@archonet.com>
Дата:
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

Re: Incr/Decr Integer

От:
"Kevin Grittner" <Kevin.Grittner@wicourts.gov>
Дата:
William Scott Jordan  wrote: 
 
> We seem to be getting a lot of deadlocks using this method under
> heavy load.
 
Could you post the exact message from one of these?
(Copy and paste if possible.)
 
-Kevin
FAQ