Skip site navigation (1) Skip section navigation (2)

Re: [PERFORM] Slow count(*) again...

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Mladen Gogala <mladen(dot)gogala(at)vmsinfo(dot)com>, "david(at)lang(dot)hm" <david(at)lang(dot)hm>, Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>, Vitalii Tymchyshyn <tivv00(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: [PERFORM] Slow count(*) again...
Date: 2011-02-01 23:03:39
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackerspgsql-performance

On 02/01/2011 05:47 PM, Bruce Momjian wrote:
> Tom Lane wrote:
>> At this point what we've got is 25% of the runtime in nodeAgg.c overhead,
>> and it's difficult to see how to get any real improvement without tackling
>> that.  Rather than apply the patch shown above, I'm tempted to think about
>> hard-wiring COUNT(*) as a special case in nodeAgg.c such that we don't go
>> through advance_aggregates/advance_transition_function at all, but just
>> increment a counter directly.  However, that would very clearly be
>> optimizing COUNT(*) and nothing else.  Given the opinions expressed
>> elsewhere in this thread that heavy reliance on COUNT(*) represents
>> bad application design, I'm not sure that such a patch would meet with
>> general approval.
>> Actually the patch shown above is optimizing COUNT(*) and nothing else,
>> too, since it's hard to conceive of any other zero-argument aggregate.
>> Anyway, if anyone is hot to make COUNT(*) faster, that's where to look.
>> I don't think any of the previous discussion in this thread is on-point
>> at all, except for the parts where people suggested avoiding it.
> Do we want a TODO about optimizing COUNT(*) to avoid aggregate
> processing overhead?

Whether or not it's bad application design, it's ubiquitous, and we 
should make it work as best we can, IMNSHO. This often generates 
complaints about Postgres, and if we really plan for world domination 
this needs to be part of it.



In response to


pgsql-performance by date

Next:From: Tom LaneDate: 2011-02-01 23:12:44
Subject: Re: [PERFORM] Slow count(*) again...
Previous:From: Bruce MomjianDate: 2011-02-01 22:47:06
Subject: Re: [PERFORM] Slow count(*) again...

pgsql-hackers by date

Next:From: Thom BrownDate: 2011-02-01 23:08:55
Subject: Re: Issues with generate_series using integer boundaries
Previous:From: Bruce MomjianDate: 2011-02-01 22:47:06
Subject: Re: [PERFORM] Slow count(*) again...

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group