Search Postgresql Archives

choosing the right locking mode

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

 



Given this type query:

        UPDATE bw_pool
        SET user_id=?
        WHERE bw_id=
                (SELECT MIN(bw_id) FROM bw_pool WHERE user_id IS NULL)
        RETURNING bw_id

The idea is to "single-threadedly" get at the next available empty slot, no matter how many such queries run in parallel. So far I've been semi-successfully using LOCK TABLE bw_pool before the UPDATE, but it deadlocks sometimes. Maybe I could use some less restrictive locking mode and prevent possible collisions at the same time?

Thanks.

--
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