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
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-announce pgsql-hackers pgsql-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

Browse pgsql-announce by date

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

Browse pgsql-hackers by date

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

Browse pgsql-patches by date

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