Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 5E93E1337B8A for ; Sat, 4 Dec 2010 13:00:09 -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 36379-04 for ; Sat, 4 Dec 2010 17:00:01 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id DF9471337B77 for ; Sat, 4 Dec 2010 13:00:00 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id oB4GxwPH024138; Sat, 4 Dec 2010 11:59:58 -0500 (EST) To: "Kevin Grittner" cc: msc@antzsystem.de, pgsql-performance@postgresql.org Subject: Re: problem with from_collapse_limit and joined views In-reply-to: <4CFA09E2020000250003829C@gw.wicourts.gov> References: <4CFA09E2020000250003829C@gw.wicourts.gov> Comments: In-reply-to "Kevin Grittner" message dated "Sat, 04 Dec 2010 09:29:06 -0600" Date: Sat, 04 Dec 2010 11:59:58 -0500 Message-ID: <24137.1291481998@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201012/39 X-Sequence-Number: 41491 "Kevin Grittner" writes: > Markus Schulz 11/24/10 1:02 PM >>> >> if i set "from_collapse_limit" (to merge the views) and >> join_collapse_limit (to explode the explicit joins) high enough >> (approx 32), all is fine (good performance). But other queries are >> really slow in our environment (therefore it's no option to raise >> the join_collapse_limit to a higher value) >> >> With defaults (8) for both, the performance is ugly > 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. regards, tom lane