Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id CC57D63440E for ; Mon, 30 Aug 2010 13:46:44 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 75691-01-2 for ; Mon, 30 Aug 2010 16:46:37 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from fep18.mx.upcmail.net (fep18.mx.upcmail.net [62.179.121.38]) by mail.postgresql.org (Postfix) with ESMTP id 1A57C633EA4 for ; Mon, 30 Aug 2010 13:46:36 -0300 (ADT) Received: from edge05.upcmail.net ([192.168.13.212]) by viefep18-int.chello.at (InterMail vM.8.01.02.02 201-2260-120-106-20100312) with ESMTP id <20100830164634.QFYC4042.viefep18-int.chello.at@edge05.upcmail.net>; Mon, 30 Aug 2010 18:46:34 +0200 Received: from wiesinger.com ([84.112.167.138]) by edge05.upcmail.net with edge id 0gmV1f0442zVakc05gmWoH; Mon, 30 Aug 2010 18:46:33 +0200 X-SourceIP: 84.112.167.138 Received: from bbs.intern (localhost [127.0.0.1]) by wiesinger.com (8.14.4/8.14.4) with ESMTP id o7UGjRQX005308; Mon, 30 Aug 2010 18:45:27 +0200 Received: from localhost (gerhard@localhost) by bbs.intern (8.14.4/8.14.4/Submit) with ESMTP id o7UGjQjS005293; Mon, 30 Aug 2010 18:45:26 +0200 Date: Mon, 30 Aug 2010 18:45:26 +0200 (CEST) From: Gerhard Wiesinger To: Tom Lane cc: Pavel Stehule , Andreas Kretschmer , pgsql-performance@postgresql.org Subject: Re: Major performance problem after upgrade from 8.3 to 8.4 In-Reply-To: <11111.1283185373@sss.pgh.pa.us> Message-ID: References: <20100830072230.GA28373@tux> <11111.1283185373@sss.pgh.pa.us> User-Agent: Alpine 2.01 (LFD 1266 2009-07-14) MIME-Version: 1.0 X-MailScanner-Information-wiesinger-com: Please contact the ISP for more information X-wiesinger-com-MailScanner-ID: o7UGjRQX005308 X-MailScanner-wiesinger-com: Found to be clean X-MailScanner-SpamCheck-wiesinger-com: not spam, SpamAssassin (not cached, score=-4.399, required 4.5, autolearn=not spam, ALL_TRUSTED -1.80, BAYES_00 -2.60) X-MailScanner-From: lists@wiesinger.com X-Cloudmark-Analysis: v=1.1 cv=Q5sYvte7CdFO72xZDcMRKl084a5I42uXcYDcqm+r+xQ= c=1 sm=0 a=-BBt41PQAQkA:10 a=ORa4HqFjfvEA:10 a=-ProOGmuAAAA:8 a=uGmitAiG5OZ3z8LKR68A:9 a=K0yQNfnbDScbCQhzDfwA:7 a=szX9YKMnwd53rXily8d0p-FbqYkA:4 a=PUjeQqilurYA:10 a=fU-A4pz3-wIA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: Content-Type: TEXT/PLAIN; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8BIT X-Archive-Number: 201008/332 X-Sequence-Number: 40175 On Mon, 30 Aug 2010, Tom Lane wrote: > Gerhard Wiesinger writes: >> I know the drawbacks of an EAV design but I don't want to discuss that. I >> want to discuss the major performance decrease of PostgreSQL 8.3 >> (performance was ok) to PostgreSQL 8.4 (performance is NOT ok). > >> Any further ideas how I can track this down? >> Can someone explain the difference in query plan from an optimizer point >> of view? > > Since you haven't shown us the 8.3 plan, it's kind of hard to speculate ;-) > > One thing that jumped out at me was that 8.4 appears to be expecting > multiple matches in each of the left-joined tables, which is why the > total rowcount estimate balloons so fast. I rather imagine that you are > expecting at most one match in reality, else the query isn't going to > behave nicely. Is this correct? Are you *sure* you analyzed all these > tables? And if that is how the data looks, where is the actual > performance problem? A bad rowcount estimate isn't in itself going > to kill you. > > FWIW, in a similar albeit toy example, I don't see any difference > between the 8.3 and 8.4 plans or cost estimates. Yes, I'm expecting only one match in reality and I thing PostgreSQL should also know that from table definition and constraints. Long answer below. Query doesn't "end" in PostgreSQL.