Re: default_transaction_isolation

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
Cc: Novice Postgresql-list <pgsql-novice(at)postgresql(dot)org>
Subject: Re: default_transaction_isolation
Date: 2007-03-23 10:26:07
Message-ID: 20070323102607.GA44256@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Thu, Mar 22, 2007 at 10:21:27PM -0700, Richard Broersma Jr wrote:
> I am wondering why is 'read commited' chosen over any of the other
> isolation levels such as SERIALIZABLE?

If you use SERIALIZABLE then some transactions will need extra logic
to handle SQLSTATE 40001 SERIALIZATION FAILURE ("could not serialize
access due to concurrent update"). The documentation suggests why
SERIALIZABLE isn't the default:

http://www.postgresql.org/docs/8.2/interactive/transaction-iso.html#XACT-SERIALIZABLE

"Since the cost of redoing complex transactions may be significant,
this mode is recommended only when updating transactions contain
logic sufficiently complex that they may give wrong answers in Read
Committed mode."

> A more generalized question would be, are there any application/RDBMS
> design considerations to help determine the best default isolation level?

In addition to the above:

"Most commonly, Serializable mode is necessary when a transaction
executes several successive commands that must see identical views
of the database."

I leave READ COMMITTED as the default and use SERIALIZABLE only in
transactions that need it, such as in reporting applications that
must see consistent results across multiple queries.

--
Michael Fuhr

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Richard Broersma Jr 2007-03-23 12:31:22 Re: default_transaction_isolation
Previous Message Richard Broersma Jr 2007-03-23 05:21:27 default_transaction_isolation