Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 9D265633ACE for ; Thu, 14 Jan 2010 13:30:40 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 34438-10 for ; Thu, 14 Jan 2010 17:30:28 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from vs137086.vserver.de (static-ip-62-75-137-86.inaddr.intergenia.de [62.75.137.86]) by mail.postgresql.org (Postfix) with ESMTP id 9CD43632B07 for ; Thu, 14 Jan 2010 13:30:29 -0400 (AST) Received: (qmail 16087 invoked from network); 14 Jan 2010 18:30:27 +0100 Received: from p54b3a04d.dip0.t-ipconnect.de (HELO a-kretschmer.de) (84.179.160.77) by static-ip-62-75-137-86.inaddr.intergenia.de with (AES256-SHA encrypted) SMTP; 14 Jan 2010 18:30:27 +0100 Received: from kretschmer by a-kretschmer.de with local (Exim 4.69) (envelope-from ) id 1NVTWb-0002NY-Rd for pgsql-performance@postgresql.org; Thu, 14 Jan 2010 18:30:25 +0100 Date: Thu, 14 Jan 2010 18:30:25 +0100 From: Andreas Kretschmer To: pgsql-performance@postgresql.org Subject: Re: bad execution plan for subselects containing windowing-function Message-ID: <20100114173025.GA8675@tux> References: <20100114170318.GA7634@tux> <25448.1263489336@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <25448.1263489336@sss.pgh.pa.us> X-OS: Debian/GNU Linux - weil ich es mir Wert bin! X-GPG-Fingerprint: EE16 3C01 7B9C 10F7 2C8B 3B86 4DB3 D9EE 7F45 84DA X-Message-Flag: "Windows" is not the answer. "Windows" is the question and the answer is "no"! X-Lugdd: Gerd Kube X-Info: My name is root. Just root. And I am licensed to kill -9 User-Agent: Mutt/1.5.18 (2008-05-17) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.005 tagged_above=-10 required=5 tests=AWL=0.595, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201001/289 X-Sequence-Number: 37169 Tom Lane wrote: > Andreas Kretschmer writes: > > No question, this is a silly query, but the problem is the 2nd query: it > > is obviously not possible for the planner to put the where-condition > > into the subquery. > > Well, yeah: it might change the results of the window functions. > I see no bug here. Your second query asks for a much more complicated > computation, it's not surprising it takes longer. Thank you for the fast answer. But sorry, I disagree. It is the same query with the same result. I can't see how the queries should return different results. What have i overlooked? tia, Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect. (Linus Torvalds) "If I was god, I would recompile penguin with --enable-fly." (unknown) Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°