Re: Locking vs. Exceptions

Поиск
Список
Период
Сортировка
От Benjamin Minshall
Тема Re: Locking vs. Exceptions
Дата
Msg-id 454A7C9B.40207@intellicon.biz
обсуждение исходный текст
Ответ на Locking vs. Exceptions  (Robins <tharakan@gmail.com>)
Список pgsql-performance
Robins wrote:
> Hi,
>
> The documentation says that function blocks with exceptions are far
> costlier than without one.
>

I recommend against using exceptions.  There is a memory leak in the
exception handler that will cause headaches if it is called many times
in the transaction.

In plpgsql, I would use:

SELECT ... FOR UPDATE;
IF FOUND THEN
    UPDATE ...;
ELSE
    INSERT ...;
END IF;


If you have multiple transactions doing this process at the same time,
you'll need explicit locking of the table to avoid a race condition.

--
Benjamin Minshall <minshall@intellicon.biz>
Senior Developer -- Intellicon, Inc.
http://www.intellicon.biz

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

Предыдущее
От: Vivek Khera
Дата:
Сообщение: Re: VACUUMs take twice as long across all nodes
Следующее
От: Arjen van der Meijden
Дата:
Сообщение: Re: Query plan for "heavy" SELECT with "lite" sub-SELECTs