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

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: So, is COUNT(*) fast now?
Date: 2011-10-23 21:52:35
Message-ID: CAMkU=1wuG21nsLNSqutrawR3M2ffU70SX5KXdCD2gWU=s81vOw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Oct 21, 2011 at 12:07 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Fri, Oct 21, 2011 at 2:33 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-10-23 22:04:33 Re: So, is COUNT(*) fast now?
Previous Message Daniel Farina 2011-10-23 20:48:06 Re: Hot Backup with rsync fails at pg_clog if under load