Re: Processing a work queue

Поиск
Список
Период
Сортировка
От Lexington Luthor
Тема Re: Processing a work queue
Дата
Msg-id f0v03g$esh$1@sea.gmane.org
обсуждение исходный текст
Ответ на Processing a work queue  (Steve Crawford <scrawford@pinpointresearch.com>)
Список pgsql-general
Steve Crawford wrote:
>
> begin;
>
> select item-id, item-info
>    from the-queue
>    where available
>    order by priority
>    limit 1
>    for update;
>
> update the-queue
>   set status = 'assigned'
>   where item-id = previously-selected-item-id;
>
> commit;
>

I do something similar in one of my apps:

BEGIN;

update the-queue
   set status = 'assigned'
   where available
   order by priority
   limit 1
   returning item-id, item-info;

COMMIT;

This should be safer and faster.

Regards,
LL

В списке pgsql-general по дате отправления:

Предыдущее
От: Listmail
Дата:
Сообщение: Re: Query in function not using index...
Следующее
От: "Simon Riggs"
Дата:
Сообщение: Re: Some problem with warm standby server