Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id E20289FBA91 for ; Fri, 10 Aug 2007 08:44:28 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 53433-09 for ; Fri, 10 Aug 2007 08:44:23 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.184]) by postgresql.org (Postfix) with ESMTP id 7E50C9FB663 for ; Fri, 10 Aug 2007 08:44:24 -0300 (ADT) Received: by nf-out-0910.google.com with SMTP id f5so263831nfh for ; Fri, 10 Aug 2007 04:44:22 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=teU0BSWGELHqjwRW4GIdCLyTbKZbxUM5DTzgILBs9BIetH+uqSF6VGFzmaK+H3+ZrCI1khLp+DhXwCwr5JslXFY3dY8sinEP9CEyj7LKgSAVPEhE+pweXBMmxOC/TwGp54pRoxdGf57hVr0Gb7e6MPM/nzLnVpBKBDpAelv2FOQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Y3vS4yU+HaqW8n5qTgSy/CzHmo+UVIi5Gtiaz2mvyMFqTEvYiPteWnYsnMmi9RQaAOSt4o0GMJmoPPLuYWy6vJ1hjNWlTCpAtF24X4mtN1nq9F3EnL5s6S3QVjM19+Xf9Gf+hZ5vPvln3xaUIXsVOYnSCpKn6Y2gUVMnVfU5Bjs= Received: by 10.78.107.8 with SMTP id f8mr1274850huc.1186746262015; Fri, 10 Aug 2007 04:44:22 -0700 (PDT) Received: by 10.78.18.9 with HTTP; Fri, 10 Aug 2007 04:44:21 -0700 (PDT) Message-ID: Date: Fri, 10 Aug 2007 17:14:21 +0530 From: "Merlin Moncure" To: runic Subject: Re: select count(*) performance Cc: pgsql-performance@postgresql.org In-Reply-To: <1186578085.034463.116030@q75g2000hsh.googlegroups.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1186578085.034463.116030@q75g2000hsh.googlegroups.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/105 X-Sequence-Number: 26235 On 8/8/07, runic wrote: > Hello Group, > > 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? This is a FAQ. This operation is optimized in some other database engines but not in PostgreSQL due to way the locking engine works. There are many workarounds, maybe the easiest is to get an approximate count using select reltuples from pg_class where relname = 'your_table' and relkind = 'r'; merlin