Re: Improving count(*) - Mailing list pgsql-hackers

From Rod Taylor
Subject Re: Improving count(*)
Date
Msg-id 1132257309.50945.78.camel@home
Whole thread Raw
In response to Re: Improving count(*)  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: Improving count(*)  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-hackers
On Thu, 2005-11-17 at 20:38 +0100, Martijn van Oosterhout wrote:
> On Thu, Nov 17, 2005 at 07:28:10PM +0000, Simon Riggs wrote:
> > One of the major complaints is always "Select count(*) is slow".
> > 
> > I have a somewhat broadbrush idea as to how we might do this (for larger
> > tables). 
> 
> It's an interesting idea, but you still run into the issue of
> visibility. If two people start a transaction, one of them inserts a
> row and then both run a select count(*), they should get different
> answers. I just don't see a way that your suggestion could possibly
> lead to that result...

The instant someone touches a block it would no longer be marked as
frozen (vacuum or analyze or other is not required) and count(*) would
visit the tuples in the block making the correct decision at that time.

-- 



pgsql-hackers by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Re: [ADMIN] ERROR: could not read block
Next
From: "Kevin Grittner"
Date:
Subject: Re: [ADMIN] ERROR: could not read block