X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 3B13A9FB216 for ; Sat, 15 Jul 2006 16:02:37 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 24461-01 for ; Sat, 15 Jul 2006 16:02:31 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by postgresql.org (Postfix) with ESMTP id 996049FA666 for ; Sat, 15 Jul 2006 16:02:31 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.7/8.13.7) with ESMTP id k6FJ2E18002587 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 15 Jul 2006 13:02:17 -0600 (MDT) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.6/8.13.6) with ESMTP id k6FJ2DKk076470; Sat, 15 Jul 2006 13:02:13 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.6/8.13.6/Submit) id k6FJ2AO8076469; Sat, 15 Jul 2006 13:02:10 -0600 (MDT) (envelope-from mfuhr) Date: Sat, 15 Jul 2006 13:02:10 -0600 From: Michael Fuhr To: Gabriele Turchi Cc: pgsql-performance@postgresql.org Subject: Re: Big differences in plans between 8.0 and 8.1 Message-ID: <20060715190210.GA76277@winnie.fuhr.org> References: <1152972852.3541.0.camel@apollo5.casa.intranet> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1152972852.3541.0.camel@apollo5.casa.intranet> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200607/151 X-Sequence-Number: 20011 On Sat, Jul 15, 2006 at 04:14:11PM +0200, Gabriele Turchi wrote: > Hi all. I have a strange (and serious) problem with an application > ported from postgres 8.0 to 8.1. > > The old installation is postgresql-8.0.4-2.FC4.1 running on a Fedora 4, > the new one is postgresql-8.1.4-1.FC5.1 running on a fedora 5. > > Some query is now _very_ slow. I've found some deep differences between > query plans. Have you run ANALYZE in 8.1? Some of the row count estimates in the 8.1 plan differ significantly from the actual number of rows returned, while in the 8.0 plan the estimates are accurate. For example, in one case the 8.0 plan shows 349 rows estimated, 349 rows returned: -> Seq Scan on registrazioni (cost=0.00..11.98 rows=349 width=19) (actual time=0.029..2.042 rows=349 loops=1) Filter: (date((now() - '02:00:00'::interval)) = data) but the 8.1 plan shows 2 rows estimated, 349 rows returned: -> Seq Scan on registrazioni (cost=0.00..11.98 rows=2 width=44) (actual time=0.025..2.315 rows=349 loops=1) Filter: (date((now() - '02:00:00'::interval)) = data) This suggests that the 8.1 statistics are out of date, possibly because ANALYZE or VACUUM ANALYZE hasn't been run since the data was loaded. Try running ANALYZE in 8.1 and post the new plans if that doesn't help. -- Michael Fuhr