Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cZsiC-0006U7-S3 for pgsql-performance@arkaria.postgresql.org; Sat, 04 Feb 2017 05:16:36 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cZsiC-0005qR-C9 for pgsql-performance@arkaria.postgresql.org; Sat, 04 Feb 2017 05:16:36 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cZsiB-0005q1-KF for pgsql-performance@postgresql.org; Sat, 04 Feb 2017 05:16:35 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cZsi8-0004Vg-QQ for pgsql-performance@postgresql.org; Sat, 04 Feb 2017 05:16:34 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v145GLt8020265; Sat, 4 Feb 2017 00:16:21 -0500 From: Tom Lane To: Titus von Boxberg cc: "pgsql-performance@postgresql.org" Subject: Re: strange and slow joining of nested views In-reply-to: References: Comments: In-reply-to Titus von Boxberg message dated "Fri, 03 Feb 2017 21:23:49 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <20263.1486185381.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 04 Feb 2017 00:16:21 -0500 Message-ID: <20264.1486185381@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Titus von Boxberg writes: > I got the following problem for which I could not find a solution by sear= ching the archives: > I have Tables Ta, Tb, Tc with primary keys as bigserials. > Ta references Tb references Tc. > Not all but most rows in Ta reference exactly one row in Tb. Hm, your problem query has 11 table scans (not to mention a couple of subplans) so you're oversimplifying here. Anyway, I think that increasing join_collapse_limit and/or from_collapse_limit to at least 11 might help. As-is, you're more or less at the mercy of whether your textual query structure corresponds to a good join order. regards, tom lane --=20 Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance