Do I need serializable for this query?

From: William Garrison <mobydisk(at)mobydisk(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Do I need serializable for this query?
Date: 2007-04-10 18:44:28
Message-ID: 461BDB0C.1030102@mobydisk.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a table that keeps running totals. It is possible that this
would get called twice simultaneously for the same UserID. Do I need to
put this in a serializable transaction? Since this gets called often,
could it be a performance problem if I make it serializable?

CREATE FUNCTION UpdateTotals(IN UserID int,
IN AddToCount int,
IN AddToSize bigint)
RETURNS void AS $$
BEGIN
UPDATE
Totals
SET
TotalSize = TotalSize + $2,
TotalCount = TotalCount + $3
WHERE
UserID = $1;
END IF;
END
$$ LANGUAGE 'plpgsql' VOLATILE;

Browse pgsql-general by date

  From Date Subject
Next Message William Garrison 2007-04-10 18:45:06 Do I need serializable for this query?
Previous Message Peter Wilson 2007-04-10 17:00:59 Re: programmatic way to fetch latest release for a given major.minor version