Re: Much Ado About COUNT(*)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Jim C(dot) Nasby" <decibel(at)decibel(dot)org>
Cc: Manfred Koizar <mkoi-pg(at)aon(dot)at>, Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, "Jonah H(dot) Harris" <jharris(at)tvi(dot)edu>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Much Ado About COUNT(*)
Date: 2005-01-17 01:34:58
Message-ID: 21183.1105925698@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-announce pgsql-hackers pgsql-patches

"Jim C. Nasby" <decibel(at)decibel(dot)org> writes:
> Actually, I guess I wasn't understanding the problem to begin with.
> You'd never go from new tuple to known good while the transaction that
> created the tuple was in-flight, right?

By definition, not.

> If that's the case, I'm not sure
> where there's a race condition. You can't delete a tuple that hasn't
> been committed, right?

The originating transaction could itself delete the tuple, but no one
else could see it yet to do that. This means that you'd have to allow
a transition directly from new tuple to possibly dead. (In the absence
of subtransactions this could be optimized into a transition directly
to known dead, but now that we have subtransactions I don't think we
can do that.)

However, the race condition comes in when someone wants to delete the
row at about the same time as someone else is trying to mark it known
good, ie, sometime *after* the originating transaction committed.
This is definitely a possible situation.

regards, tom lane

In response to

Browse pgsql-announce by date

  From Date Subject
Next Message Roberto Andrade Fonseca 2005-01-18 02:26:26 SQL Commands in PostgreSQL 7.4.2 form Palm Devices
Previous Message Jim C. Nasby 2005-01-17 01:32:02 Re: Much Ado About COUNT(*)

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2005-01-17 02:35:40 Re: Latest Turkish translation updates
Previous Message Jim C. Nasby 2005-01-17 01:32:02 Re: Much Ado About COUNT(*)

Browse pgsql-patches by date

  From Date Subject
Next Message Peter Eisentraut 2005-01-17 02:35:40 Re: Latest Turkish translation updates
Previous Message Jim C. Nasby 2005-01-17 01:32:02 Re: Much Ado About COUNT(*)