Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id DBA7D1337B90 for ; Sat, 4 Dec 2010 14:46:31 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 39682-01 for ; Sat, 4 Dec 2010 18:46:24 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.tastatur-junkie.de (static.206.114.40.188.clients.your-server.de [188.40.114.206]) by mail.postgresql.org (Postfix) with ESMTP id 84DD31337B56 for ; Sat, 4 Dec 2010 14:46:24 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by mail.tastatur-junkie.de (Postfix) with ESMTP id E39B6F302DE; Sat, 4 Dec 2010 19:46:23 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mail.tastatur-junkie.de Received: from mail.tastatur-junkie.de ([127.0.0.1]) by localhost (st90.tastatur-junkie.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0wDlrbdIgu85; Sat, 4 Dec 2010 19:46:22 +0100 (CET) Received: from niasmobil.localnet (cotb-4d05be51.pool.mediaWays.net [77.5.190.81]) by mail.tastatur-junkie.de (Postfix) with ESMTPSA; Sat, 4 Dec 2010 19:46:22 +0100 (CET) From: Markus Schulz Organization: AntzSystem GmbH To: pgsql-performance@postgresql.org Subject: Re: problem with from_collapse_limit and joined views Date: Sat, 4 Dec 2010 19:46:21 +0100 User-Agent: KMail/1.13.5 (Linux/2.6.36-trunk-686; KDE/4.4.5; i686; ; ) Cc: Tom Lane References: <4CFA09E2020000250003829C@gw.wicourts.gov> <24137.1291481998@sss.pgh.pa.us> In-Reply-To: <24137.1291481998@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201012041946.21722@Mail-Followup-To> 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 X-Spam-Level: X-Archive-Number: 201012/41 X-Sequence-Number: 41493 Am Samstag 04 Dezember 2010 schrieb Tom Lane: > "Kevin Grittner" writes: ... > > One option would be to create a different user for running queries > > which read from complex views such as this. > > If you don't want to change the collapse limits, the only other > option is to restructure this specific query so that its syntactic > structure is closer to the ideal join order. Look at the plan you > get in the good-performing case and re-order the join syntax to look > like that. no that's not working in this case. view1 and view2 are written with explicit joins and no better join was possible. Each view works perfect standalone. In my above example i have rewritten view1 without explicit joins only for testing purpose. Without explicit joins i can gather the optimal query plan from a slightly higher from_collapse_limit (see workaround 2 from my initial posting). If both views using explicit joins the from_collapse_limit is useless (only join_collapse_limit usable). The problem exists only for "view1 JOIN view2" and that pgsql don't "see" that an element of view2 contains an index-access for reducing the data from view1. Only if he can break the complete join of both views into one query-plan he can "see" this. But for this i must raise the limits. Looks like some improvement to the geco optimizer was needed here ;) regards msc