special cases of true serializability

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>
Subject: special cases of true serializability
Date: 2009-12-28 23:36:19
Message-ID: 1262043379.22866.1363.camel@jdavis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I was thinking about true serializability, and started thinking that
there are a lot of special cases where true serializability can be
achieved without modification.

For instance, the following is problematic:

BEGIN;
SELECT count(*) FROM mytable;
...

because future insert/update/deletes may be based on that count, so we
essentially would have to lock out write to mytable.

However,

BEGIN READ ONLY;
SELECT count(*) FROM mytable;
...

is fine, because snapshot isolation already gives true serializability.

And inserts (that don't read any tables) are always safe as well.

Also, in snapshot isolation mode, simple updates and deletes that have a
simple predicate involving a unique key also give true serializability.

It seems like the kinds of transactions that fall outside of these
special cases are exactly the kind of transactions where serializability
is most important -- reading an unknown number of tuples and then
writing. People executing transactions like that are probably willing to
pay some performance cost to ensure correct results.

How hard would it be to reliably detect the transactions for which
snapshot isolation already means true serializability?

Regards,
Jeff Davis

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kevin Grittner 2009-12-28 23:49:32 Re: Serializable implementation
Previous Message Andres Freund 2009-12-28 23:31:56 Re: [HACKERS] Faster CREATE DATABASE by delaying fsync (was 8.4.1 ubuntu karmic slow createdb)