Re: So, is COUNT(*) fast now? - Mailing list pgsql-hackers

From Andres Freund
Subject Re: So, is COUNT(*) fast now?
Date
Msg-id 201110221149.37177.andres@anarazel.de
Whole thread Raw
In response to Re: So, is COUNT(*) fast now?  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: So, is COUNT(*) fast now?  (desmodemone <desmodemone@gmail.com>)
Re: So, is COUNT(*) fast now?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Friday, October 21, 2011 08:14:12 PM Robert Haas wrote:
> On Fri, Oct 21, 2011 at 2:08 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > Robert Haas <robertmhaas@gmail.com> writes:
> >> On Fri, Oct 21, 2011 at 1:18 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >>> I don't know why you'd imagine that touching an index is free, or even
> >>> cheap, CPU-wise.  The whole point of the index-only optimization is to
> >>> avoid I/O.  When you try it on a case where there's no I/O to be saved,
> >>> and no shared-buffers contention to be avoided, there's no way it's
> >>> going to be a win.
> >> 
> >> Well, call me naive, but I would have thought touching six times less
> >> data would make the operation run faster, not slower.
> > 
> > It's not "touching six times less data".  It's touching the exact same
> > number of tuples either way, just index tuples in one case and heap
> > tuples in the other.
> 
> Yeah, but it works out to fewer pages.
But access to those is not sequential. I guess if you measure cache hit ratios 
the index scan will come out significantly worse.


Andres


pgsql-hackers by date:

Previous
From: nrdb
Date:
Subject: database file encryption.
Next
From: desmodemone
Date:
Subject: Re: So, is COUNT(*) fast now?