Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 6EC352E2DA4 for ; Fri, 11 Jan 2008 22:11:29 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 87301-06 for ; Fri, 11 Jan 2008 22:11:19 -0400 (AST) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 3BBB72E28AD for ; Fri, 11 Jan 2008 22:11:20 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id m0C2BI0P029726; Fri, 11 Jan 2008 21:11:18 -0500 (EST) To: "James DeMichele" cc: pgsql-performance@postgresql.org Subject: Re: Simple select, but takes long time In-reply-to: <082D8A131DF72A4D88C908A1AD3DEB2201AF140E@mail-1.rf.lan> References: <082D8A131DF72A4D88C908A1AD3DEB2201AF140E@mail-1.rf.lan> Comments: In-reply-to "James DeMichele" message dated "Fri, 11 Jan 2008 17:33:54 -0800" Date: Fri, 11 Jan 2008 21:11:18 -0500 Message-ID: <29725.1200103878@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/99 X-Sequence-Number: 28338 "James DeMichele" writes: > I am having a really hard time trying to figure out why my simple > count(*) query is taking so long. I have a table with 1,296,070 rows in > it. There are 2 different types of information that each row has that I > care about: Hmm, the EXPLAIN output works out to about 5 msec per row, which is not too out of line for a lot of random-access disk fetches. I'm surprised the planner bothered with an indexscan for this --- I'd bet a seqscan might be faster, seeing you're having to read about 1% of the rows which will likely touch most pages of the table anyway. Or a bitmap indexscan might be even better. What do you get if you try the EXPLAIN ANALYZE with enable_indexscan = off? regards, tom lane