Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-announcepgsql-hackerspgsql-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

pgsql-announce by date

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

pgsql-hackers by date

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

pgsql-patches by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group