Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 1B2D51337999 for ; Tue, 1 Feb 2011 19:12:56 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 05740-01 for ; Tue, 1 Feb 2011 23:12:49 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id B7FDB13364DE for ; Tue, 1 Feb 2011 19:12:48 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p11NCi2d005101; Tue, 1 Feb 2011 18:12:44 -0500 (EST) To: Andrew Dunstan cc: Bruce Momjian , Mladen Gogala , "david@lang.hm" , Craig Ringer , Vitalii Tymchyshyn , PostgreSQL-development Subject: Re: [PERFORM] Slow count(*) again... In-reply-to: <4D48914B.4050403@dunslane.net> References: <201102012247.p11Ml6u02682@momjian.us> <4D48914B.4050403@dunslane.net> Comments: In-reply-to Andrew Dunstan message dated "Tue, 01 Feb 2011 18:03:39 -0500" Date: Tue, 01 Feb 2011 18:12:44 -0500 Message-ID: <5100.1296601964@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201102/78 X-Sequence-Number: 180867 Andrew Dunstan writes: > 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. >> 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. I don't think that saving ~25% on COUNT(*) runtime will help that at all. The people who complain about it expect it to be instantaneous. If this sort of hack were free, I'd be all for doing it anyway; but I'm concerned that adding tests to enable a fast path will slow down every other aggregate, or else duplicate a lot of code that we'll then have to maintain. regards, tom lane