Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id C09A4632FD8 for ; Wed, 14 Jul 2010 09:30:40 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 70836-10 for ; Wed, 14 Jul 2010 12:30:33 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp-vbr11.xs4all.nl (smtp-vbr11.xs4all.nl [194.109.24.31]) by mail.postgresql.org (Postfix) with ESMTP id 174D2632B68 for ; Wed, 14 Jul 2010 09:30:32 -0300 (ADT) Received: from spoetnik.xs4all.nl (spoetnik.xs4all.nl [82.95.228.65]) by smtp-vbr11.xs4all.nl (8.13.8/8.13.8) with ESMTP id o6ECUUU5021153 for ; Wed, 14 Jul 2010 14:30:30 +0200 (CEST) (envelope-from reinoud.v@n.leeuwen.net) Received: by spoetnik.xs4all.nl (Postfix, from userid 1000) id DE0751CC95; Wed, 14 Jul 2010 14:30:29 +0200 (CEST) Date: Wed, 14 Jul 2010 14:30:29 +0200 From: Reinoud van Leeuwen To: pgsql-sql@postgresql.org Subject: Re: Question on COUNT performance Message-ID: <20100714123029.GH62243@spoetnik.xs4all.nl> Mail-Followup-To: pgsql-sql@postgresql.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.13 (2006-08-11) X-Virus-Scanned: by XS4ALL Virus Scanner X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.8 tagged_above=-5 required=5 tests=BAYES_50=0.8, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201007/62 X-Sequence-Number: 34375 On Wed, Jul 14, 2010 at 09:58:10PM +1000, Anders ??stergaard Jensen wrote: > Hello mailing list, > > I have a performance problem with my postgres 8.4.4 database. The query is > the following: > > SELECT count(*) AS count_all FROM "plan_events" WHERE (f_plan_event_acl(17, > plan_events.id)) > > QUERY PLAN > > ------------------------------------------------------------------------------------------------------------------------ > Aggregate (cost=2859.77..2859.78 rows=1 width=0) (actual > time=4641.720..4641.720 rows=1 loops=1) > -> Seq Scan on plan_events (cost=0.00..2851.44 rows=3331 width=0) > (actual time=32.821..4640.116 rows=2669 loops=1) > Filter: f_plan_event_acl(17, id) > Total runtime: 4641.753 ms > (4 rows) > > > > What can I do to improve the performance? Have you tried 'select count (1)..."? Reinoud -- __________________________________________________ "Nothing is as subjective as reality" Reinoud van Leeuwen reinoud.v@n.leeuwen.net http://reinoud.van.leeuwen.net kvk 27320762 __________________________________________________