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

From Jeff Janes
Subject Re: So, is COUNT(*) fast now?
Date
Msg-id CAMkU=1wuG21nsLNSqutrawR3M2ffU70SX5KXdCD2gWU=s81vOw@mail.gmail.com
Whole thread Raw
In response to Re: So, is COUNT(*) fast now?  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: So, is COUNT(*) fast now?
List pgsql-hackers
On Fri, Oct 21, 2011 at 12:07 PM, Robert Haas <robertmhaas@gmail.com> wrote:
> On Fri, Oct 21, 2011 at 2:33 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>> I think HeapTupleSatisfiesMVCC is probably being skipped anyway in
>>> this case, since all the heap pages should be PD_ALL_VISIBLE.
>>
>> Proves my point ;-) ... you're comparing a code path that's been beat on
>> for *years* with one that just got written.
>
> I know.  I wrote a chunk of it.  :-)  My point is just that it'd be
> nice to make it better.
>
> Anyhow, here's the scoop.  On my desktop machine running F14, running
> SELECT sum(1) FROM pgbench_accounts in a tight loop, 60 s worth of
> oprofile data:
>
> 176830   13.0801  postgres                 postgres                 ExecProject

Hi Robert,

count(*) and sum(1) do different things internally, and in my hands
sum(1) is ~10% slower.

I don't know how to dump the output of ExecBuildProjectionInfo into a
human readable form, so I don't know the basis of the difference.  But
I wonder if using count(*) would lower the weight of the ExecProject
function.


Cheers,

Jeff


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: termination of backend waiting for sync rep generates a junk log message
Next
From: Daniel Farina
Date:
Subject: Re: Hot Backup with rsync fails at pg_clog if under load