Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id B5B3937BFD1 for ; Mon, 29 Sep 2008 20:20:24 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 75818-10 for ; Mon, 29 Sep 2008 20:20:21 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id EAE9037BCB3 for ; Mon, 29 Sep 2008 20:20:21 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m8TNKKhS025756; Mon, 29 Sep 2008 19:20:20 -0400 (EDT) To: Doug Eck cc: pgsql-performance@postgresql.org Subject: Re: Identical DB's, different execution plans In-reply-to: <822909.77097.qm@web45203.mail.sp1.yahoo.com> References: <822909.77097.qm@web45203.mail.sp1.yahoo.com> Comments: In-reply-to Doug Eck message dated "Mon, 29 Sep 2008 11:18:45 -0700" Date: Mon, 29 Sep 2008 19:20:20 -0400 Message-ID: <25755.1222730420@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200809/267 X-Sequence-Number: 31580 Doug Eck writes: > The new plan from the slower db: > -> Index Scan using t1_uc2 on t1 (cost=0.00..25604.74 rows=204906 width=32) (actual time=0.061..327.285 rows=8438 loops=1) > Filter: active This seems a bit fishy. In the first place, with such a simple filter condition it shouldn't be that far off on the rowcount estimate. In the second place, the cost estimate is more than twice what the other server estimates to do a seqscan and sort of the same data, and the rowcount estimate is five times as much. So there's something really significantly different about the t1 tables in the two cases. The first thing you ought to do is to look at the pg_class.relpages and reltuples entries for t1 in both databases. What I am suspecting is that for some reason the "slow" db has suffered a lot of bloat in that table, leading to a corresponding increase in the cost of a seqscan. If so, a VACUUM FULL or CLUSTER should fix it, though you'll next need to look into why routine vacuumings weren't happening. (It looks like t2 may be a bit bloated as well.) If that's not it, we'll need to probe deeper ... regards, tom lane