Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id F33DC9FB87C for ; Fri, 18 May 2007 16:59:32 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 45630-01 for ; Fri, 18 May 2007 16:59:27 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 1206F9FB873 for ; Fri, 18 May 2007 16:59:25 -0300 (ADT) 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 l4IJxMD8001737; Fri, 18 May 2007 15:59:23 -0400 (EDT) To: "Tyrrill, Ed" cc: pgsql-performance@postgresql.org Subject: Re: Slow queries on big table In-reply-to: References: Comments: In-reply-to "Tyrrill, Ed" message dated "Fri, 18 May 2007 11:30:12 -0700" Date: Fri, 18 May 2007 15:59:22 -0400 Message-ID: <1736.1179518362@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/343 X-Sequence-Number: 24733 "Tyrrill, Ed" writes: > Index Scan using backup_location_pkey on backup_location > (cost=0.00..1475268.53 rows=412394 width=8) (actual > time=3318.057..1196723.915 rows=2752 loops=1) > Index Cond: (backup_id = 1070) > Total runtime: 1196725.617 ms If we take that at face value it says the indexscan is requiring 434 msec per actual row fetched. Which is just not very credible; the worst case should be about 1 disk seek per row fetched. So there's something going on that doesn't meet the eye. What I'm wondering about is whether the table is heavily updated and seldom vacuumed, leading to lots and lots of dead tuples being fetched and then rejected (hence they'd not show in the actual-rows count). The other thing that seems pretty odd is that it's not using a bitmap scan --- for such a large estimated rowcount I'd have expected a bitmap scan not a plain indexscan. What do you get from EXPLAIN ANALYZE if you force a bitmap scan? (Set enable_indexscan off, and enable_seqscan too if you have to.) regards, tom lane