Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 107622E00B6 for ; Thu, 6 Mar 2008 01:43:05 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 97895-04 for ; Thu, 6 Mar 2008 01:43:02 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.232]) by postgresql.org (Postfix) with ESMTP id 745CA2E00B2 for ; Thu, 6 Mar 2008 01:43:02 -0400 (AST) Received: by wr-out-0506.google.com with SMTP id c49so2393338wra.19 for ; Wed, 05 Mar 2008 21:43:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=vv7CUpALe2A2MBlMx8ZOPKwajC3aU5rjJ6ZoaNQ1A/4=; b=a+fsLg42Wn5IOc2CFxoCIVWK2Uq1tZf1I/infWn4Z4SjrCG4PDnbvO8TYPge39MXxH8osBGvEjXxu3HPCzQAY/PFUoMDp8w3Axl6eaZYM257MJ4D63znNaOrzRe0d+/qsy02Z0I5xbspl+uXDw3vRwSlxgpEeDXuClFuuxIz2fs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=a3hGSA6G/q1jSDC8IrUnzR78MOPrks3WVPrkyalq9R+LyWKeWZ/vKcJPGvoOQYz1Xu1CLNBTpne98rAT8Am0C1goUnOPHx1Xkn86eDlNzCYD/tTtcybBdsoobRdeQFoM87I4DJyl1W14CdGRk4VHPm7qEsLBYBTUVxL6UZo57EU= Received: by 10.100.253.12 with SMTP id a12mr9110700ani.92.1204782181949; Wed, 05 Mar 2008 21:43:01 -0800 (PST) Received: by 10.100.105.20 with HTTP; Wed, 5 Mar 2008 21:43:01 -0800 (PST) Message-ID: Date: Thu, 6 Mar 2008 11:13:01 +0530 From: "sathiya psql" To: pgsql-performance@postgresql.org Subject: count * performance issue In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_3466_2902788.1204782181940" References: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200803/86 X-Sequence-Number: 29040 ------=_Part_3466_2902788.1204782181940 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline count(*) tooks much time... but with the where clause we can make this to use indexing,... what where clause we can use?? Am using postgres 7.4 in Debian OS with 1 GB RAM, am having a table with nearly 50 lakh records, it has more than 15 columns, i want to count how many records are there, it is taking nearly 17 seconds to do that... i know that to get a approximate count we can use SELECT reltuples FROM pg_class where relname = TABLENAME; but this give approximate count, and i require exact count... ------=_Part_3466_2902788.1204782181940 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline count(*) tooks much time...

but with the where clause we can make this to use indexing,... what where clause we can use??

Am using postgres 7.4 in Debian OS with 1 GB RAM,

am having a table with nearly 50 lakh records,

it has more than 15 columns, i want to count how many records are there, it is taking nearly 17 seconds to do that...

i know that to get a approximate count we can use
         SELECT reltuples FROM pg_class where relname = TABLENAME;

but this give approximate count, and i require exact count...

------=_Part_3466_2902788.1204782181940--