Re: I/O on select count(*) - Mailing list pgsql-performance

From Alvaro Herrera
Subject Re: I/O on select count(*)
Date
Msg-id 20080516201528.GJ13061@alvh.no-ip.org
Whole thread Raw
In response to Re: I/O on select count(*)  (Greg Smith <gsmith@gregsmith.com>)
Responses Re: I/O on select count(*)
Re: I/O on select count(*)
List pgsql-performance
Greg Smith wrote:

> After reading the code and that documentation a bit, the part I'm still
> not sure about is whether the CLOG entry is created when the XID is
> assigned and then kept current as the state changes, or whether that
> isn't even in CLOG until the transaction is committed.  It seems like the
> latter, but there's some ambiguity in the wording and too many code paths
> for me to map right now.

pg_clog is allocated in pages of 8kB apiece(*).  On allocation, pages are
zeroed, which is the bit pattern for "transaction in progress".  So when
a transaction starts, it only needs to ensure that the pg_clog page that
corresponds to it is allocated, but it need not write anything to it.

(*) Each transaction needs 2 bits, so on a 8 kB page there is space for
4 transactions/byte * 8 pages * 1kB/page = 32k transactions.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

pgsql-performance by date:

Previous
From: Craig Ringer
Date:
Subject: Re: very slow left join
Next
From: "Scott Marlowe"
Date:
Subject: Re: Regexps - never completing join.