Re: So, is COUNT(*) fast now?

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: So, is COUNT(*) fast now?
Date: 2011-10-21 17:20:46
Message-ID: CA+TgmobQudhhS6r9ge+Q9FQguKmrzRbp-qnE5pU12jJG-fQviQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Oct 21, 2011 at 1:18 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> That's a bit disappointing - it's now more than a third faster to do
>> the sequential scan, even though the sequential scan has to touch six
>> times as many blocks (at scale factor 20, index is 43 MB, table is 256
>> MB) all of which are in cache.  Of course, touching that many fewer
>> blocks does have some advantages if there is concurrent activity on
>> the system, but it still seems unfortunate that the ratio of runtime
>> to blocks touched is more than 8x higher for the index-only case.
>
> 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.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Florian Pflug 2011-10-21 17:40:14 Re: Synchronized snapshots versus multiple databases
Previous Message Robert Haas 2011-10-21 17:18:23 Re: Synchronized snapshots versus multiple databases