Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 2CDA537BCB8 for ; Mon, 29 Sep 2008 21:17:52 -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 90152-01 for ; Mon, 29 Sep 2008 21:17:47 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from n71.bullet.mail.sp1.yahoo.com (n71.bullet.mail.sp1.yahoo.com [98.136.44.36]) by postgresql.org (Postfix) with SMTP id F0DD537B9B1 for ; Mon, 29 Sep 2008 21:17:47 -0300 (ADT) Received: from [216.252.122.219] by n71.bullet.mail.sp1.yahoo.com with NNFMP; 30 Sep 2008 00:17:44 -0000 Received: from [69.147.65.167] by t4.bullet.sp1.yahoo.com with NNFMP; 30 Sep 2008 00:17:44 -0000 Received: from [127.0.0.1] by omp502.mail.sp1.yahoo.com with NNFMP; 30 Sep 2008 00:17:44 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 766753.65219.bm@omp502.mail.sp1.yahoo.com Received: (qmail 58387 invoked by uid 60001); 30 Sep 2008 00:17:44 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Date:From:Reply-To:Subject:To:Cc:MIME-Version:Content-Type:Message-ID; b=YFpIwITXW6JSaFC9bEPfGQ4PO10TxDYOotTgZZN7HEe3xY/dOA57eGMit5NbEtryPLPcGlj+hKD4M+Y0nhkAg21SBqebdKoibMGhTeyQonXQpdlqwGr6k/KPcw4szPkO9wqZ0TwAlk3j/82wonMfMoPiOD62OU1fYlzwFlgoiBg=; X-YMail-OSG: rq.BcnUVM1kW483Bcsw56t9JaQmkHfqioSachIdlqxT.p3Iy_e6NH2WivGelzgO0lrKbjJ.AKF0HBs5l.YwARo1yRjGY2Jj_XpUm6R3ccRC3jg7FmdO1.qaJlYqgm6HPuZjUykYOemk.NcSMkdKdmRvLYd9_.GKEQj6hKTCN8dhYPfolyA-- Received: from [64.126.29.122] by web45201.mail.sp1.yahoo.com via HTTP; Mon, 29 Sep 2008 17:17:44 PDT X-Mailer: YahooMailRC/1096.28 YahooMailWebService/0.7.218.2 Date: Mon, 29 Sep 2008 17:17:44 -0700 (PDT) From: Doug Eck Reply-To: Doug Eck Subject: Re: Identical DB's, different execution plans To: Tom Lane Cc: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1641135722-1222733864=:58055" Message-ID: <650568.58055.qm@web45201.mail.sp1.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200809/268 X-Sequence-Number: 31581 --0-1641135722-1222733864=:58055 Content-Type: text/plain; charset=us-ascii Tom, You nailed it. The t1 table was using 9600 relpages versus 410 after the vacuum full. The two databases are now showing similar execution plans and times. Thanks for your help. It is greatly appreciated. Doug Eck ----- Original Message ---- From: Tom Lane To: Doug Eck Cc: pgsql-performance@postgresql.org Sent: Monday, September 29, 2008 6:20:20 PM Subject: Re: [PERFORM] Identical DB's, different execution plans 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 --0-1641135722-1222733864=:58055 Content-Type: text/html; charset=us-ascii
Tom,

You nailed it.  The t1 table was using 9600 relpages versus 410 after the vacuum full.  The two databases are now showing similar execution plans and times.

Thanks for your help.  It is greatly appreciated.

Doug Eck

----- Original Message ----
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Doug Eck <deck1@yahoo.com>
Cc: pgsql-performance@postgresql.org
Sent: Monday, September 29, 2008 6:20:20 PM
Subject: Re: [PERFORM] Identical DB's, different execution plans

Doug Eck <deck1@yahoo.com> 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

--0-1641135722-1222733864=:58055--