Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id E83729FB5AD for ; Thu, 9 Aug 2007 11:44:48 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 31374-02-2 for ; Thu, 9 Aug 2007 11:44:22 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id E84AD9FB72F for ; Thu, 9 Aug 2007 11:44:40 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 439C431440; Thu, 9 Aug 2007 16:44:38 +0200 (MET DST) From: "slawekj" X-Newsgroups: pgsql.performance Subject: Re: select count(*) performance Date: Thu, 9 Aug 2007 16:44:41 +0200 Organization: Hub.Org Networking Services Lines: 20 Message-ID: References: <1186578085.034463.116030@q75g2000hsh.googlegroups.com> X-Complaints-To: usenet@news.hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138 X-RFC2646: Format=Flowed; Original To: pgsql-performance@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 200708/98 X-Sequence-Number: 26228 > I'm new in PostgreSQL Business, therefore please forgive me a "newbie" > Question. I have a table with ca. 1.250.000 Records. When I execute > a "select count (*) from table" (with pgAdmin III) it takes about 40 > secs. > I think that takes much to long. Can you please give me hints, where > I can search for Improvements? > TIA, Det maybe try change shared_buffers and test it, or you can create trigger on this table after insert and delete if insert then increse value in another table "counts" if delete then decrese and now you dont must execute select count(*) ... but execute select my_count from counts where tablename='your_table' sj