Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 638549FB5B6 for ; Tue, 23 Jan 2007 20:52:09 -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 05559-06 for ; Tue, 23 Jan 2007 20:51:55 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from smtp5.clear.net.nz (smtp5.clear.net.nz [203.97.33.68]) by postgresql.org (Postfix) with ESMTP id C8DA19FB51D for ; Tue, 23 Jan 2007 20:51:59 -0400 (AST) Received: from [192.168.1.11] (121-72-69-246.dsl.telstraclear.net [121.72.69.246]) by smtp5.clear.net.nz (CLEAR Net Mail) with ESMTP id <0JCC004TAL2KZ110@smtp5.clear.net.nz> for pgsql-performance@postgresql.org; Wed, 24 Jan 2007 13:51:57 +1300 (NZDT) Date: Wed, 24 Jan 2007 13:51:51 +1300 From: Mark Kirkwood Subject: Re: slow result In-reply-to: <5.0.2.1.2.20070123133416.00cf43b8@pop.univ-montp2.fr> To: Laurent Manchon Cc: pgsql-performance@postgresql.org Message-id: <45B6ADA7.80204@paradise.net.nz> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7bit References: <5.0.2.1.2.20070123133416.00cf43b8@pop.univ-montp2.fr> User-Agent: Thunderbird 1.5.0.9 (X11/20061227) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/355 X-Sequence-Number: 22956 Laurent Manchon wrote: > Hi, > > 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. Can you post the results of: analyze verbose tbl; explain analyze select count(*) from tbl; The first will give us some info about how many pages tbl has (in 7.4 ISTR it does not state the # of dead rows... but anyway), the second should help us deduce why it is so slow. Also as others have pointed out, later versions are quite a bit faster for sequential scans... Cheers Mark