From: Benjamin Minshall <minshall@intellicon.biz>
To: robins@pobox.com
Cc: pgsql-performance@postgresql.org
Subject: Re: Locking vs. Exceptions
Date: Thu, 02 Nov 2006 18:17:47 -0500
Message-ID: <454A7C9B.40207@intellicon.biz> (raw)
In-Reply-To: <36af4bed0611020445s445e3fe8o344f529190a8dfea@mail.gmail.com>
References: <36af4bed0611020445s445e3fe8o344f529190a8dfea@mail.gmail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: minshall@intellicon.biz, robins@pobox.com
Subject: Re: Locking vs. Exceptions
In-Reply-To: <454A7C9B.40207@intellicon.biz>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox