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: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: "Jonah H(dot) Harris" <jharris(at)tvi(dot)edu>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Much Ado About COUNT(*)
Date: 2005-01-13 05:39:56
Message-ID: 5528.1105594796@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-announcepgsql-hackerspgsql-patches
Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
>> Ah, right, I missed the connection.  Hmm ... that's sort of the inverse
>> of the "killed tuple" optimization we put in a release or two back,
>> where an index tuple is marked as definitely dead once it's committed
>> dead and the deletion is older than all active transactions.

> Yes, it is sort of the reverse, but how do you get around the delete
> case?

A would-be deleter of a tuple would have to go and clear the "known
good" bits on all the tuple's index entries before it could commit.
This would bring the tuple back into the "uncertain status" condition
where backends would have to visit the heap to find out what's up.
Eventually the state would become certain again (either dead to
everyone or live to everyone) and one or the other hint bit could be
set again.

The ugly part of this is that clearing the bit is not like setting a
hint bit, ie it's not okay if we lose that change.  Therefore, each
bit-clearing would have to be WAL-logged.  This is a big part of my
concern about the cost.

			regards, tom lane

In response to

Responses

pgsql-announce by date

Next:From: Christopher Kings-LynneDate: 2005-01-13 10:12:49
Subject: Re: Much Ado About COUNT(*)
Previous:From: Bruce MomjianDate: 2005-01-13 05:25:09
Subject: Re: Much Ado About COUNT(*)

pgsql-hackers by date

Next:From: Mark WongDate: 2005-01-13 07:49:02
Subject: Re: pg_autovacuum w/ dbt2
Previous:From: Bruce MomjianDate: 2005-01-13 05:25:09
Subject: Re: Much Ado About COUNT(*)

pgsql-patches by date

Next:From: Christopher Kings-LynneDate: 2005-01-13 10:12:49
Subject: Re: Much Ado About COUNT(*)
Previous:From: David FetterDate: 2005-01-13 05:33:30
Subject: Returning multiple cursors from PL/PgSQL

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