Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 0C7599FB4F1 for ; Tue, 23 Jan 2007 09:53:31 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 55456-03 for ; Tue, 23 Jan 2007 09:53:22 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mx00.pub.collaborativefusion.com (mx00.pub.collaborativefusion.com [206.210.89.199]) by postgresql.org (Postfix) with ESMTP id 5E46F9FB28B for ; Tue, 23 Jan 2007 09:53:27 -0400 (AST) Received: from vanquish.pgh.priv.collaborativefusion.com (vanquish.pgh.priv.collaborativefusion.com [192.168.2.61]) (SSL: TLSv1/SSLv3,256bits,AES256-SHA) by wingspan with esmtp; Tue, 23 Jan 2007 08:53:25 -0500 id 0005642B.45B61355.00000CA0 Date: Tue, 23 Jan 2007 08:53:25 -0500 From: Bill Moran To: Laurent Manchon Cc: pgsql-performance@postgresql.org Subject: Re: slow result Message-Id: <20070123085325.216d4a4c.wmoran@collaborativefusion.com> In-Reply-To: <5.0.2.1.2.20070123113422.00d189e8@pop.univ-montp2.fr> References: <5.0.2.1.2.20070123113422.00d189e8@pop.univ-montp2.fr> Organization: Collaborative Fusion X-Mailer: Sylpheed 2.3.0 (GTK+ 2.10.7; i386-portbld-freebsd6.1) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/349 X-Sequence-Number: 22950 In response to Laurent Manchon : > > I have a slow response of my PostgreSQL database 7.4 using this query below > on a table with 800000 rows: > > select count(*)from tbl; > > PostgreSQL return result in 28 sec every time. > although MS-SQL return result in 0.02 sec every time. > > My server is a DELL PowerEdge 2600 with bi-processor Xeon at 3.2 Ghz > with 3GBytes RAM While there's truth in everything that's been said by others, the query should not take _that_ long. I just tried a count(*) on a table with 460,000 rows, and it took less than a second. count(*) in PostgreSQL is not likely to compare to most other RDBMS for the reasons others have stated, but counting 800,000 rows shouldn't take 28 seconds. The standard question applies: have you vacuumed recently? > My PostgreSQL Conf is > ********************* > log_connections = yes > syslog = 2 > effective_cache_size = 50000 > sort_mem = 10000 > max_connections = 200 > shared_buffers = 3000 > vacuum_mem = 32000 > wal_buffers = 8 > max_fsm_pages = 2000 > max_fsm_relations = 100 > > Can you tell me is there a way to enhence performance ? On our 4G machines, we use shared_buffers=240000 (which equates to about 2G). The only reason I don't set it higher is that FreeBSD has a limit on shared memory of 2G. The caveat here is that I'm running a mix of 8.1 and 8.2. There have been significant improvements in both the usage of shared memory, and the optimization of count(*) since 7.4, so the first suggestion I have is to upgrade your installation. -- Bill Moran Collaborative Fusion Inc.