Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 5476F6348C8 for ; Tue, 3 Mar 2009 13:39:03 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 49708-04 for ; Tue, 3 Mar 2009 13:38:40 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from bifrost.lang.hm (mail.lang.hm [64.81.33.126]) by mail.postgresql.org (Postfix) with ESMTP id 7CA2A633CA5 for ; Tue, 3 Mar 2009 13:38:37 -0400 (AST) Received: from asgard.lang.hm (asgard.lang.hm [10.0.0.100]) by bifrost.lang.hm (8.13.4/8.13.4/Debian-3) with ESMTP id n23HcSPV010035; Tue, 3 Mar 2009 09:38:28 -0800 Date: Tue, 3 Mar 2009 09:38:28 -0800 (PST) From: david@lang.hm X-X-Sender: dlang@asgard.lang.hm To: Aaron Guyon cc: pgsql-performance@postgresql.org Subject: Re: Postgres 8.3, four times slower queries? In-Reply-To: Message-ID: References: <2870.1236050632@sss.pgh.pa.us> User-Agent: Alpine 1.10 (DEB 962 2008-03-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII 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: 200903/29 X-Sequence-Number: 32951 On Tue, 3 Mar 2009, Aaron Guyon wrote: > On Mon, Mar 2, 2009 at 10:23 PM, Tom Lane wrote: > >> Are you sure you are comparing apples to apples here? Same configure >> options for the builds, same parameter values in postgresql.conf, both >> databases ANALYZEd, etc? And are they running on the same hardware? >> > > Thank you for looking at this Tom. Yes, we have made sure we are comparing > apples to apples here. The postgresql.confs are identical, as are the > configure flags: > --disable-debug --enable-shared --enable-thread-safety --with-perl > --with-pam --without-docdir --without-tcl --without-python --without-krb5 > --without-ldap --without-bonjour --enable-integer-datetimes > --prefix=/opt/postgresql > > However, the db was not analyzed. I'll attached the new explain analyze of > the queries with the db analyzed, but 8.2 still beats 8.3. > > The tests are both being run on the same machine, a Quad-core AMD Opteron > Processor 2212 > (each with 1024 KB cache) and 4GB of RAM. > > I find it telling that the query plan differs so much between postgres 8.2. > and > 8.3. For example, why does the 8.3. planner choose to perform so many seq > scans? I know seq scans are faster than index scans for small tables, but > these tables have 60K+ rows... surely an index scan would have been a better > choice here? If you look at the 8.2. query plan, it is very clean in > comparison, index scans all the way through. I can't help but think the 8.3 > planner is simply failing to make the right choices in our case. Another > question would be, why are there so many hash joins in the 8.3 plan now? > All > our indexes are btrees... > > Any light that can be shed on what going on with the 8.3. planner would be > much > appreciated. Thanks in advance. if you haven't done a vaccum analyse on either installation then postgres' idea of what sort of data is in the database is unpredictable, and as a result it's not surprising that the two systems guess differently about what sort of plan is going to be most efficiant. try doing vaccum analyse on both databases and see what the results are. David Lang