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

From Martijn van Oosterhout
Subject Re: Improving count(*)
Date
Msg-id 20051117193816.GH22933@svana.org
Whole thread Raw
In response to Improving count(*)  (Simon Riggs <simon@2ndquadrant.com>)
Responses Re: Improving count(*)
Re: Improving count(*)
List pgsql-hackers
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...

There is no unique answer to count(*), it all depends on who is looking
(sounds like relativity :) ). If you can sort that, you're well over
90% of the way.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Some array semantics issues
Next
From: "Jonah H. Harris"
Date:
Subject: Re: Improving count(*)